Insert specific text in blank cell with VBA

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, in Column E(5) of worksheet 72 HR I would like “TBD” entered in blank cells. Column D(4) will determine how many rows I need to go down to. In other words any data in Column D then TBD will be placed in Column E. Thank you.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
How about
VBA Code:
Sub Livin()
   With Sheets("72 HR")
     .Range("E5:E" & .Range("D" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).Value = "TBD"
   End With
End Sub
 
Upvote 0
The code works quite happily without that change. ;)

PS. If you want to format code yourself, use the Rich tags rather than the VBA tags
 
Upvote 0
How about
VBA Code:
Sub Livin()
   With Sheets("72 HR")
     .Range("E5:E" & .Range("D" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).Value = "TBD"
   End With
End Sub
Thank you for the prompt reply. I'm afraid I may have not been to clear. It is only with data in Column D that I would need TBA in Column E on the same row. If it is blank in Column D then leave blank in Column E. Cheers!

tbd.JPG
 
Upvote 0
Are the values in col D hard values or formulae?
 
Upvote 0
There is no formula to get those. They exist before TBA formula is used. So I take it they are hard
 
Upvote 0
Ok, how about
VBA Code:
Sub Livin()

   With Sheets("72 HR")
      .Range("D5", .Range("D" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Offset(, 1).SpecialCells(xlBlanks).Value = "TBD"
   End With
End Sub
 
Upvote 0
I'm afraid it is still adding a TBD in Column E to a blank cell when there is a blank cell in Column D. Only if there is a time in Column D would I want TBD put in the blank into the corresponding cell in Column E. If a particular cell in Column D is blank then no action is needed. Thank you.
 
Upvote 0
In that case your "blank" cells are not completely empty.
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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