ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to copy cell values from one sheet to another (https://www.excelbanter.com/excel-programming/436926-code-copy-cell-values-one-sheet-another.html)

Talat via OfficeKB.com

Code to copy cell values from one sheet to another
 
Hi,

Can anybody help me with this?

I recorded a macro which copies cells value from one open excel file into
another excel file where it needs to find the lasy used row, and then copy
into cells in the row below it. But the resultant VBA code references actual
cell values eg Range("A15658").Select which does not work because next time
the macro is run it should be +1

steps might be
open worksheet a and Sheets
Copy from
sheetA, row 10, columnB
to worksheetB
last used row+1, column A

Copy from
sheetA, row 10, columnD
to worksheetB
last used row+1, column B ..... etc

Once I sort this out, I have one more query. If I can't sort it out myself,
would like to get back to you or the forum again.

Many thanks.

Talât

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1


Gary''s Student

Code to copy cell values from one sheet to another
 
This will copy from Sheet1 cell D10 to Sheet2 first available cell in column B:

Sub CopyDemo()
Dim s1 As Worksheet, s2 As Worksheet
Dim rSource As Range, rDest As Range
Set s1 = Worksheets("Sheet1")
Set s2 = Worksheets("Sheet2")
Set rSource = s1.Range("D10")
n = s2.Cells(Rows.Count, 2).End(xlUp).Row + 1
Set rDest = s2.Range("B" & n)

rSource.Copy rDest

End Sub

--
Gary''s Student - gsnu200909


"Talat via OfficeKB.com" wrote:

Hi,

Can anybody help me with this?

I recorded a macro which copies cells value from one open excel file into
another excel file where it needs to find the lasy used row, and then copy
into cells in the row below it. But the resultant VBA code references actual
cell values eg Range("A15658").Select which does not work because next time
the macro is run it should be +1

steps might be
open worksheet a and Sheets
Copy from
sheetA, row 10, columnB
to worksheetB
last used row+1, column A

Copy from
sheetA, row 10, columnD
to worksheetB
last used row+1, column B ..... etc

Once I sort this out, I have one more query. If I can't sort it out myself,
would like to get back to you or the forum again.

Many thanks.

Talât

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200912/1

.



All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com