Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My code isn't working and I don't know why

Status
Not open for further replies.

andy7172289

Technical User
Aug 16, 2016
19
GB

The code below stops when it gets to the second row of the first section. Can anyone tell me why? I've double checked all the tabs have the correct naming conventions...

LastRow = Sheets("RR Master").Range("A" & Rows.Count).End(xlUp).Row
Sheets("RR S&C").Range("A2").Select
Selection.AutoFill Destination:=Range("A2:L" & LastRow)

Sheets("RR PL").Range("A2").Select
Selection.AutoFill Destination:=Range("A2:I" & LastRow)

Sheets("RR Validation").Range("A2").Select
Selection.AutoFill Destination:=Range("A2:J" & LastRow)


Thanks guys, problem solved. The issue now lies with the 'Selection.AutoFill Destination:=Range(A2:I" & LastRow)'
 
I believe you need to first select the sheet and then the range.

Code:
 LastRow = Sheets("RR Master").Range("A" & Rows.Count).End(xlUp).Row
[highlight #FCE94F] Sheets("RR S&C").Select[/highlight]
 Sheets("RR S&C").Range("A2").Select
 Selection.AutoFill Destination:=Range("A2:L" & LastRow)

Also, consider using TGML tags to format your code. It is typically much easier to read.

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016
 
You need not select anything...
Code:
LastRow = Sheets("RR Master").Range("A" & Rows.Count).End(xlUp).Row
 Sheets("RR S&C").Range("A2").AutoFill Destination:=Range("A2:L" & LastRow)

However, on what sheet is your destination range?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top