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")this range is only qualified to whatever sheet is active at run-time. You loop through that range twice, and the second time you do it will have no effect because it's just repeating what it did in first loop. You need to reassign this for each sheet or use some alternate method to process each sheet.