Forum Discussion

Deleted's avatar
Deleted
May 10, 2018

Gathering and copying cell data from multiple cells.

On my sheet what I want to do is to press a command button and have the data from different cells go to cells A1-A4. I currently have the data working properly to pull into A1, it is pulling from G9, then B1, then G10 and lastly C1, works perfect, but then I want the same VBA script to start filling A2 with data, for example, I want it to start in A2 copying G12 and E1 and lastly G13, and so on, to copy and populate some info not on there yet into A3 and A4, but I can not seem to figure out how to tell VBA to start copying into the cells under A1 consecutivly. The file is attached and here is the VBA I am currently using.

 

---------------------------------------------------------------

 

Option Explicit

Sub copyRow()
Dim ws As Worksheet
Dim lRow As Long

 

' define which worksheet to work on, i.e. replace Sheet1 with the name of your sheet
Set ws = ActiveWorkbook.Sheets("Sheet1")

 

' determine the last row with content in column A and add one
lRow = ws.Cells(Rows.Count, "A").End(xlUp).Row + 3

 

' combine A1 and A2 and copy into column A, next empty row
ws.Range("A" & lRow) = ws.[G9] & ws.[B1] & ws.[G10] & " " & ws.[C1]

 

End Sub

 

-------------------------------------------------------

 

Any help is appreciated! Cheers!

No Replies

Resources