Selecting Group of Rows with spaces in between

VBAEnjoi

New Member
Joined
Sep 30, 2018
Messages
33
Hi,

I have a s/sheet which has multiple blocks of Rows.
I used Lastrow to get the last row and the Startrow to get the last block of rows.
However, I am unable to select two other blocks above the last block.
There is a single blank row in between these rows.

Lastrow = .Cells(.Rows.Count, "D").End(xlUp).Row
Startrow = .Cells(.Rows.Count, "D").End(xlUp).End(xlUp).Row
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Keep adding the .End(xlup) until you get to what you need
 
Upvote 0
Thanks, I tried the same one but didn't work

New range as Lastrow1 and Startrow1
Lastrow = .Cells(.Rows.Count, "D").End(xlUp).Row
to
Lastrow1 = .Cells(.Rows.Count, "D").End(xlUp).End(xlUp).Row

and
Start Row from
Startrow = .Cells(.Rows.Count, "D").End(xlUp).End(xlUp).Row

Startrow1 = .Cells(.Rows.Count, "D").End(xlUp).End(xlUp)..End(xlUp).Row
 
Upvote 0
You have an extra . before the last End(xlup)
What exactly are your trying to do?
 
Upvote 0
Hi Fluff,

Removed the extra . before the last End(xlup)

Have to select say Row 5 to Row 12 - Then enter a Vlookup formula
Then select say Row 14 to Row 25 enter a VLookup formula
Then select say Row 27 to Row 102 and enter another VLookupformula

The Ranges are dynamic and there is one row space between these ranges
 
Last edited:
Upvote 0
Will it always start at row5?
 
Upvote 0
Yes, it can start from a fixed row say 5 or 1 or 2.
I meant the Start Row will be same across any sheets.
Only it may not necessarily be 5, it could be a 1 or a 2 etc.
 
Last edited:
Upvote 0
What column needs the formula?
 
Upvote 0
Maybe something like
Code:
Sub AddFormula()
   Dim Rng As Range
   For Each Rng In Range("D:D").SpecialCells(xlConstants).Areas
      Rng.Offset(, 3).FormulaR1C1 = "=vlookup(rc[-3],c10:c11,2,0)"
   Next Rng
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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