Finding cells with values

aa2000

Board Regular
Joined
Aug 3, 2011
Messages
87
Hello All

I am trying to write a macro which looks at the value in a cell, and if it is empty moves up one cell, and does so continuously until the active cell has a value, at which point it makes the active cell bold.

I tried using the .Find method but that code did not stop at the first cell with a value and just made every cell with a value bold.

Does anybody know how to do this?

Cheers
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
say it's column "A" you're looking at

Code:
cells(rows.count,"A").end(xlup).font.bold = true
 
Upvote 0
I may be using this code wrong, but it only seems to make the first cell (from the bottom) in column A bold.
Is it possible to get it to search from any cell.

Code:
If c.Value = "KF" Then 
If c.Offset(0, -3).Value = "" Then Cells(Rows.Count, "A").End(xlUp).Font.Bold = True

Can I replace the "End" with c.Offset(0, -3) perhaps?

Cheers
 
Upvote 0
Is it possible to select c.Offset(0, -3) then use ActiveCell instead of .End as the starting point for the code?

Cheers
 
Upvote 0
Your initial description implied you only wanted to make the first non blank cell from the bottom bold.

Now you're saying you want the bold font to start from a row with specific content and to cover more than one cell.

Could you please restate your requirements?
 
Upvote 0
Sorry for the confusion, Weaver.

What I want to do is go through a column (D in my case) and if a certain value exists in Column d, then look at the cell in column A on the same row. If the cell is empty, then I want the macro to go up until it finds the first non blank cell and make it bold.

Is that clearer?

Cheers
 
Upvote 0
Actually Weaver, I was able to solve that problem by using to following code:

Code:
If c.Value = "Something" Then If c.Offset(0, -3).Value = "" Then c.Offset(0, -3).Select
    ActiveCell.End(xlUp).Font.Bold = True

Thank you for your help!
 
Upvote 0
Just so you know, you don't need to 'select'

Code:
If c.Value = "Something" Then If c.Offset(0, -3).Value = "" Then c.Offset(0, -3).End(xlUp).Font.Bold = True
should do the same job.

Won't make a lot of difference for one, but if you were doing many, it's much more efficient.
 
Upvote 0

Forum statistics

Threads
1,222,749
Messages
6,167,967
Members
452,158
Latest member
MattyM

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