Code questions
Ron
Hope the below helps.......
Sub Macro()
Dim wbBook1 As Workbook
Dim wbBook2 As Workbook
Dim wsSheet1 As Worksheet
Dim wsSheet2 As Worksheet
Dim varRange As Variant
Dim lngLastRow As Long
'To reference a open workbook (unsaved)
'To reference a open workbook (already saved) add extension
Set wbBook1 = Workbooks("Book1")
Set wbBook2 = Workbooks("Book3")
'Refer the worksheets
Set wsSheet1 = wbBook1.Worksheets("Sheet2")
Set wsSheet2 = wbBook2.Worksheets("Sheet1")
varRange = wsSheet1.Rows(1)
'To copy to first row
wsSheet2.Rows(1) = varRange
'Next blank cell in Col A
lngLastRow = ActiveSheet.Range("A1").End(xlDown).Row + 1
wsSheet2.Rows(lngLastRow) = varRange
'Last available row in Column A
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
wsSheet2.Rows(lngLastRow) = varRange
End Sub
If this post helps click Yes
---------------
Jacob Skaria
"Ron" wrote:
Can someone provide:
1. the syntax for copying a complete line from one spreadsheet to another?
Does the second one have to be open?
2. syntax for inserting a complete line in a different spreadsheet, on the
next blank line of a sheet, moving the rest on the lines down?
3. the syntax for copying a complete line at the end of a sheet on a
different spreadsheetspreadsheet.
I'm going to try to use that to put together a complicated macro.
Thanks,
Ron
|