VBA: In a Column Fill empty Cells with Entry from Pop Up Window

LNG2013

Active Member
Joined
May 23, 2011
Messages
465
Hello,
I need assistance with a little bit of VBA code.
The code needs to:
  • Identify all the blank cells in Column D, It is the last column.
  • Display a pop up dialog / Userform
  • A response is entered by the user in the dialog.
  • Whatever is entered into that dialog will then fill ALL of the blank cells with the response.


Example of Data Set:

A
B
C
D
Date
Food
Price
Discount
1/15/2019
Apple
1.00
1/15/2019
Orange
1.00
0
1/16/2019
Peach
.75
1/16/2019
Banana
2.00
.10
1/16/2019
Cereal
3.00
1/16/2019
Pop Tarts
2.50
0

<tbody>
</tbody>
Dialog : Enter the Discount
User Enters: .25
Result:



A
B
C
D
Date
Food
Price
Discount
1/15/2019
Apple
1.00
.25
1/15/2019
Orange
1.00
0
1/16/2019
Peach
.75
.25
1/16/2019
Banana
2.00
.10
1/16/2019
Cereal
3.00
.25
1/16/2019
Pop Tarts
2.50
0

<tbody>
</tbody>
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try
Code:
On Error Resume Next
Range("D:D").SpecialCells(xlCellTypeBlanks).Value = Application.InputBox("fill with what", Type:=2)
On Error Goto 0
 
Upvote 0
Thank you that works Mike!
Small Snafu - In the example above their are 6 rows, ideally I would want it to stop after the last Row in Column A, any thoughts?
Currently it keeps repeating in Column D into infinity past the last value in the Row for Column A.
 
Upvote 0
Try
Code:
On Error Resume Next
Range("D:D").SpecialCells(xlCellTypeBlanks).Value = Application.InputBox("fill with what", Type:=2)
On Error Goto 0


Thank you that works Mike!
Small Snafu - In the example above their are 6 rows, ideally I would want it to stop after the last Row in Column A, any thoughts?
Currently it keeps repeating in Column D into infinity past the last value in the Row for Column A.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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