rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 574
- Office Version
- 365
- Platform
- Windows
I have two tabs in my worksheet. Sheet 1 is my Master sheet with several columns of data. I would like to select a column and then starting at row 2, go to the first non blank cell below row 2, and then transfer the data in column A to sheet 2 (Chart page) to cell A3, then transfer the current column of data in the active row on the Master page to B3 and the first column to the right of my active column on the Master page to C3. Then I want to go to the next non blank cell on the Master page, and do the same transfer to A4, B4, and C4 on the chart page. I would like to continue all the way down to the last row on the Master sheet.
In my code below the macro crashes on the "StartRow = Sheets("Chart").Rows(3)" with a Run-Time Error 13, Type Mismatch. What do I need to do to fix this. Secondly will the rest of the code do what I describe above?
Thanks for the help.
In my code below the macro crashes on the "StartRow = Sheets("Chart").Rows(3)" with a Run-Time Error 13, Type Mismatch. What do I need to do to fix this. Secondly will the rest of the code do what I describe above?
Thanks for the help.
VBA Code:
Sub Group_Transfer()
Application.ScreenUpdating = False
Dim LastRow As Long
Dim sht As Worksheet
Dim MyCol As Long
Dim iCounter As Long
Dim MyRange As Range
Dim StartRow As Long
Dim n As Long
MyCol = ActiveCell.Column
Set sht = ActiveSheet
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
Set MyRange = Rows("3:" & LastRow)
StartRow = Sheets("Chart").Rows(3)
' Column Heading Transfer
Sheets("Chart").Range("K2").Value = Sheets("Master").Range(ActiveCell.Column & "1").Value
Sheets("Master").Range(MyCol & "2").Select
' Start looping through the range.
For iCounter = MyRange.Rows.Count To LastRow Step ActiveCell.End(xlDown).Row
For n = 0 To LastRow
' Data transfer
Sheets("Chart").Range("A" & StartRow + n).Value = Sheets("Master").Range("A" & ActiveCell.Row).Value
Sheets("Chart").Range("B" & StartRow + n).Value = Sheets("Master").Range(MyCol & ActiveCell.Row).Value
Sheets("Chart").Range("C" & StartRow + n).Value = Sheets("Master").Range(MyCol + 1 & ActiveCell.Row).Value
Next n
Next iCounter
Application.ScreenUpdating = True
End Sub