' If the cells of second row contain the word "Total" ,I want to copy paste the entire column of that cell to the end of the table.(Later, I also want to delete the original table, but I have not come to it.
Dim PRTSLastRow As Long
Dim PRTSLastCol As Long
Dim ColLtr As String
Dim LastColLtr As String
Dim tempColLtr As String
Dim Total As String
W = ActiveWorkbook.Name
PRTSLastCol = Worksheets("PRTSCarrierCount").Cells(1, Columns.Count).End(xlToLeft).Column
PRTSLastRow = Worksheets("PRTSCarrierCount").Cells(Rows.Count, 1).End(xlUp).Row
j = 1
Workbooks(W).Sheets("PRTSCarrierCount").Activate
For i = 1 To PRTSLastCol
Total = Cells(1, i).Value
If InStr(1, CStr(Total), "Total") > 0 Then
ColLtr = Replace(Cells(1, i).Address(True, False), "$1", "")
LastColLtr = Replace(Cells(1, PRTSLastCol + j).Address(True, False), "$1", "")
Range("ColLtr & 1: & ColLtr & PRTSLastRow").Select
'Columns("ColLtr & : & ColLtr").Select
Selection.Copy
Range("LastColLtr & 1").Select
ActiveSheet.Paste
j = j + 1
End If
Next i
Aucun commentaire:
Enregistrer un commentaire