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
 
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

Looks complex. Will try and revert.

Thanks for putting this together.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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
Remember my penchant for one-liners? :lol: Well, then if your code above does what the OP wants, then I think this should also...
Code:
[table="width: 500"]
[tr]
	[td]Sub AddFormula()
  Intersect(Columns("D").SpecialCells(xlConstants).EntireRow, Columns("G")).Formula = "=VLOOKUP(D3,$J:$K,2,0)"
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
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