Help with Last Cell VBA

chaddres

Board Regular
Joined
Jun 14, 2014
Messages
143
Office Version
  1. 365
Platform
  1. Windows
What am I doing wrong with the code in red? I want to select Cell A2 on Sheet 2 and then select the data in A2:A LRowS1 (the last row in that column). Thank you so much for any guidance.

Sheets("Macro Workbook").Select
Range("A1").Select
'Sheets.Add After:=ActiveSheet
'Sheets("Sheet5").Select
'Sheets("Sheet5").Name = "Time Export"
Sheets("Sheet 1").Select
Range("A:A,C:C,D:D,G:G,H:H,P:P,V:V").Select
Selection.Copy
Sheets("Time Export").Select
ActiveSheet.Paste
Range("A1").Select
LRowTE = Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("Sheet 2").Select
Range("A2").Select
LRowS1 = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2:A&LRowS1,C2:CLRowS1,D2:DLrowS1,G2:GLrowS1,H2:HLrowS1,P2:PLrowS1,V2:VLrowS1").Select

Selection.Copy
Sheets("Time Export").Select
Range("ALrowTE").Select
ActiveSheet.Paste
 
Glad you sorted it, but you have some redundant lines that could lead to problems, try
VBA Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    Sheets("Macro Workbook").Select
    Range("A1").Select
    'Sheets.Add After:=ActiveSheet
    'Sheets("Sheet5").Select
    'Sheets("Sheet5").Name = "Time Export"
    Sheets("Sheet 1").Select
    Range("A:A,C:C,D:D,G:G,H:H,P:P,V:V").Select
    Selection.Copy
    Sheets("Time Export").Select
    Range("A1").Select
    ActiveSheet.Paste
    Range("A1").Select
    LrowTE = Cells(Rows.Count, 1).End(xlUp).Row + 1
    With Sheets("Sheet 2")
      Intersect(.Range("A2", .Range("A" & Rows.Count).End(xlUp)).EntireRow, .Range("A:A,C:D,G:H,P:P,V:V")).Copy Sheets("Time Export").Range("A" & LrowTE)
    End With
    
End Sub
 
Upvote 0
Solution

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top