VBA: Lastrow + Range selection keeps going wrong ?

NessPJ

Active Member
Joined
May 10, 2011
Messages
431
Office Version
  1. 365
Hey all,

I have a piece of code where i determine the last row in a sheet and use this value to make a selection, to copy this range to another sheet.
For some reason i can't explain the wrong selections keeps being made.

I made a screenshot to show whats going wrong: Click
(The green square is the selection that keeps being made).
The Range i would want to be selected would be: D6:F10.

The code i am using is here:
Code:
    Sheets("Stamgegevens").Select
 
    Lastrow = Range("F65536").End(xlUp).Row
    Selection.Range("D6:F" & Lastrow).Copy
 
    Sheets("Kentekenlijst").Select
    Range("F3").Select
    ActiveSheet.Paste

I simplified the selection/copy command to see where it all goes wrong..
Before i was using this:
Code:
    Sheets("Stamgegevens").Select
 
    Lastrow = Range("F65536").End(xlUp).Row
    Selection.Range("D6:F" & Lastrow).Copy Destination:=Sheets("Kentekenlijst").Range("F3")

Any help would be very much appreciated!
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try

Code:
Dim Lastrow As Long
Lastrow = Sheets("Stamgegevens").Cells(Rows.Count, "F").Row
Sheets("Stamgegevens").Range("D6:F" & Lastrow).Copy Destination:=Sheets("Kentekenlijst").Range("F3")

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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