hi i want to copy using dynamic range my code is as follows
it gives object error i want to do something of this type using varColumn this works fine when using column c or some defined one i have attached the workbook![]()
Sub FlowchartProcess1_Click() Dim wksQA As Excel.Worksheet Dim wksEmp As Excel.Worksheet Dim varColumn Dim Lastrow As Long Dim lastrow2 As Long Lastrow = Sheets("QA_Matrix").Range("c" & Rows.Count).End(xlUp).Row Sheets("ind").Range("b9:b" & Lastrow + 1000).ClearContents Sheets("ind").Range("b9:b" & Lastrow - 1).Value = Sheets("QA_matrix").Range("c11:c" & Lastrow).Value Set wksEmp = Sheets("ind") Set wksQA = Sheets("QA_Matrix") ' find employee column on matrix sheet varColumn = Application.Match(wksEmp.Range("C4").Value, wksQA.Range("7:7"), 0) lastrow2 = Sheets("QA_Matrix").Range("varColumn" & Rows.Count).End(xlUp).Row If IsError(varColumn) Then ' no match so display error message MsgBox "No match found for employee: " & strName Else ' copy employee data across wksQA.Range("varColumn11:varColumn" & Lastrow).Value = wksEmp.Range("b9:b" & Lastrow - 1).Value End If End Sub
Bookmarks