Checking for empty cells

Status
Not open for further replies.

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Thanks oldbrewer, could you explain the code? Does it mean if Cell a1 is '-' or <empty>, lookup a1 in range(mytable) and return the 2nd column?
I was looking for something more complicated (not the most ideal word to describe)
This is what I've got so far:
Code:
    If Aluminium Then NonBlankRow = Worksheets(WorksheetName).Range(Worksheets(WorksheetName).Cells(10, Column), Worksheets(WorksheetName).Cells(26, Column)).Cells.SpecialCells(xlCellTypeConstants).Count
    If Copper Then NonBlankRow = Worksheets(WorksheetName).Range(Worksheets(WorksheetName).Cells(28, Column), Worksheets(WorksheetName).Cells(49, Column)).Cells.SpecialCells(xlCellTypeConstants).Count
    If Aluminium Then StartRow = Range(Worksheets(WorksheetName).Cells(10, Column), Worksheets(WorksheetName).Cells(26, Column)).Find("-", Cells(Rows.Count, Column), xlValues, xlWhole, , xlNext).Address
    If Copper Then StartRow = Range(Worksheets(WorksheetName).Cells(28, Column), Worksheets(WorksheetName).Cells(49, Column)).Find("-", Cells(Rows.Count, Column), xlValues, xlWhole, , xlNext).Address
    EndRow = StartRow + NonBlankRow - 1
 
Upvote 0
my formula means if A1 is "-" then return a blank, otherwise look up the value of A1 in the lookup table

show us some of your data with random "-" and we can look for a work round
 
Upvote 0
Hi oldbrewer,
how do I upload the picture? I tried inserting the url but nothing happens.
-
-
10
20
30
-
40
50
-
-

<tbody>
</tbody>
This is roughly what it looks like. There's a index match line running through it, so when it hits a '-', it will skip on to the next value and not display an error.
 
Upvote 0
I will make up a little spreadsheet and devise some code for you in a couple of hours - basically you need a loop that visits each cell in the column in turn but if it finds a blank move on without doing anything - some thing like

for j=1 to 1000
if cells(j,1)="-" then goto 100
tot=tot+1
cells(tot,5)=vlookup(cells(j,1),mytable,2)
100 next j

don't rely on above it is to show the approach....
 
Upvote 0
I think it will help if you display tables as you have done in post #6

1. What is your INDEX MATCH formula (please post it)
2. What are the lookup value(s) used by MATCH
3. What result do you anticipate?
 
Upvote 0
Here's the index-match formula:
Code:
VoltageDropDC = WorksheetFunction.Index(Table, WorksheetFunction.Match(Val(LoadCurrentText), ConductorRow, 1) + j, VoltageDropColumnDC)
It looks up Val(LoadCurrentText) and returns an offset value from a column in Table. So if it's empty, it basically looks up the next value below. And if it has reached the end of the table, it returns the value from that last row, and displays a message to let the user know the value returned may be incorrect.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,261
Messages
6,123,931
Members
449,134
Latest member
NickWBA

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