Do I need .SELECT here? Columns not filling as expected.

logandiana

Board Regular
Joined
Feb 21, 2017
Messages
107
Here's a short section of my code.

Code:
With comp
    .Range("A1").PasteSpecial xlPasteValues
    .Rows("1:3").Delete
    .Columns("B:B").Delete
    .Columns("A:B").RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo
LR2 = comp.Cells(Rows.Count, 1).End(xlUp).Row
    .Range("A1:B" & LR2).Copy
End With
With temp
    .Range("J2").PasteSpecial xlPasteValues
LR3 = temp.Cells(Rows.Count, 10).End(xlUp).Row
    .Range("Z2:Z" & LR3).Value = Range("K2:K" & LR3).Value
    .Range("K2:K" & LR3).Value = Range("J2:J" & LR3).Value

Once it pastes into J2 on temp it doesn't seem to do the following lines of code.
The code doesn't stop, it just ignores it.
LR3 does get defined.
If I put select in there, like this
Code:
With temp
    .Select
    .Range("J2").PasteSpecial xlPasteValues
LR3 = temp.Cells(Rows.Count, 10).End(xlUp).Row
    .Range("Z2:Z" & LR3).Value = Range("K2:K" & LR3).Value
    .Range("K2:K" & LR3).Value = Range("J2:J" & LR3).Value
it works as it should, but why do I need to do that for it to work.
 
Glad we could help & thanks for the feedback
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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