I'm trying to copy the values in column c starting from range C6 until the last data row to cell V6 one by one and the call the macro But my code is not working.
Sub Copy()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Worksheets("contacts")
LastRow = ws.Range("C" & Rows.Count).End(xlUp).Row
ws.Range("V6").Value = ws.Range("C6:C" & LastRow).Value
Call ga
End Sub
The problem is that ws.Range("V6") is a single cell and ws.Range("C6:C" & LastRow) probably contains multiple cells. You cannot assign a multi-cell range to a single cell.
Do you want to call ga for each cell? If so, you have to write a For ... Next loop.
If not: please explain more clearly what you want.
I want to call the "ga" each time a cell in column C is copied to V6.
For example when the code is run,
cells of column C will get copied starting from row 6; one by one until the last data row. Each time the cell is copied, it will run the code "ga"
Sub Copy()
Dim ws As Worksheet
Dim LastRow As Long
Dim c As Range
Set ws = Worksheets("contacts")
LastRow = ws.Range("C" & Rows.Count).End(xlUp).Row
For Each c In ws.Range("C6:C" & LastRow)
ws.Range("V6").Value = c.Value
Call ga
Next c
End Sub
Sub copy()
Dim r As Long
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Worksheets("contacts")
LastRow = ws.Range("C" & Rows.Count).End(xlUp).Row
For r = 6 To LastRow
ws.Range("V6").Value = ws.Range("C" & r).Value
Call ga
Next r
End Sub