Skip to main content
added 48 characters in body
Source Link
user10003190
user10003190

I copy and paste one sheet to the other, but the amount of data always changes. Whenever I paste, a column at the end of the sheet labeled 'Grand Total' appears but it messes up the data on another sheet so I want to delete it. It deletes from the second code but not the first. I need help figuring out why the first doesn't work.

 Set RidGrTotal = Range("B1:AH3000")  isum.Sheets("pivot custom").Activate  For Each cell In RidGrTotal   If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents  Next  Set RidGrandTotal = Range("B1:AH3000")  isum.Sheets("Pivot to MW").Activate  For Each cell In RidGrandTotal   If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents  Next 

I copy and paste one sheet to the other, but the amount of data always changes. Whenever I paste, a column at the end of the sheet labeled 'Grand Total' appears but it messes up the data on another sheet so I want to delete it. It deletes from the second code but not the first. I need help figuring out why the first doesn't work.

Set RidGrTotal = Range("B1:AH3000") isum.Sheets("pivot custom").Activate For Each cell In RidGrTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next Set RidGrandTotal = Range("B1:AH3000") isum.Sheets("Pivot to MW").Activate For Each cell In RidGrandTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next 

I copy and paste one sheet to the other, but the amount of data always changes. Whenever I paste, a column at the end of the sheet labeled 'Grand Total' appears but it messes up the data on another sheet so I want to delete it. It deletes from the second code but not the first. I need help figuring out why the first doesn't work.

 Set RidGrTotal = Range("B1:AH3000")  isum.Sheets("pivot custom").Activate  For Each cell In RidGrTotal   If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents  Next  Set RidGrandTotal = Range("B1:AH3000")  isum.Sheets("Pivot to MW").Activate  For Each cell In RidGrandTotal   If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents  Next 
Post Closed as "Duplicate" by David Zemens excel
cleaned up code
Source Link
PeterT
  • 8.6k
  • 1
  • 19
  • 46

I copy and paste one sheet to the other, but the amount of data always changes. Whenever I paste, a column at the end of the sheet labeled 'Grand Total' appears but it messes up the data on another sheet so I want to delete it. It deletes from the second code but not the first. I need help figuring out why the first doesn't work.

Set RidGrTotal = Range("B1:AH3000") isum.Sheets("pivot custom").Activate For Each cell In RidGrTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next Set RidGrandTotal = Range("B1:AH3000") isum.Sheets("Pivot to MW").Activate For Each cell In RidGrandTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next

Set RidGrTotal = Range("B1:AH3000") isum.Sheets("pivot custom").Activate For Each cell In RidGrTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next Set RidGrandTotal = Range("B1:AH3000") isum.Sheets("Pivot to MW").Activate For Each cell In RidGrandTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next 

I copy and paste one sheet to the other, but the amount of data always changes. Whenever I paste, a column at the end of the sheet labeled 'Grand Total' appears but it messes up the data on another sheet so I want to delete it. It deletes from the second code but not the first. I need help figuring out why the first doesn't work.

Set RidGrTotal = Range("B1:AH3000") isum.Sheets("pivot custom").Activate For Each cell In RidGrTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next Set RidGrandTotal = Range("B1:AH3000") isum.Sheets("Pivot to MW").Activate For Each cell In RidGrandTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next

I copy and paste one sheet to the other, but the amount of data always changes. Whenever I paste, a column at the end of the sheet labeled 'Grand Total' appears but it messes up the data on another sheet so I want to delete it. It deletes from the second code but not the first. I need help figuring out why the first doesn't work.

Set RidGrTotal = Range("B1:AH3000") isum.Sheets("pivot custom").Activate For Each cell In RidGrTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next Set RidGrandTotal = Range("B1:AH3000") isum.Sheets("Pivot to MW").Activate For Each cell In RidGrandTotal If cell.Value = "Grand Total" Then cell.EntireColumn.ClearContents Next 
edited title
Link
user6749601
user6749601

VBA column will notdoesn’t delete whenever header appears on sheet

Source Link
user10003190
user10003190
Loading