Get next empty cell in column B and return the value in column A

skacutter

New Member
Joined
Dec 23, 2016
Messages
18
In VBA I need to Get the next empty cell in column B and return the value in column A. Column A has a unique ID number so the entire table has values for column A. I need the first row where B is empty to return to a text-box the value in A and then fill the rest of the columns in that row.
 

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.
start from B2.
I assume cell B1 contains a header, so it is not blank and I also assume Column B cells do not contain formulas. If those two assumptions are valid, then this single line of code will give you the value you seek...

ValueInColA = Columns("B").SpecialCells(xlBlanks)(1).Offset(, 1).Value
 
Upvote 0
Rick,

Nice solution! I like the logic!

However, you have a minor typo in there. It should be:
.Offset(, -1)
instead of
.Offset(, 1)
otherwise you are returning the value from column C, not column A.
 
Last edited:
Upvote 0
Rick,

Nice solution! I like the logic!

However, you have a minor typo in there. It should be:
.Offset(, -1)
instead of
.Offset(, 1)
otherwise you are returning the value from column C, not column A.
Whoops! Thanks for catching that. :oops:
 
Upvote 0
Sorry, One last question. We found the blank in column B and returned the value in column A..... Now how do I get a handle on that row so I can fill in the rest of the columns?
 
Upvote 0
If you want to capture the row number that blank is found on, you can do so like this:
Code:
myRow = Columns("B").SpecialCells(xlBlanks)(1).Row
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,150
Members
452,383
Latest member
woodsfordg

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