Null values

RoseChapman

New Member
Joined
Jun 12, 2018
Messages
40
Hello,

I do not have values in all cells of my spreadsheet and I have to add "0", to those cells with nothing on it between D to CU columns. Is there a way to do this with MACROS? I would really appreciate your help

Many thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
If the cells are genuinely empty try
Code:
Sub RoseChapman()
   Range("D:CU").SpecialCells(xlBlanks).Value = 0
End Sub
 
Upvote 0
Thank you very much Moderator,
I have added the following, but it does not work, not sure why, could you please help?. Many thanks

Worksheets("sheet2").Range("D2:CU").SpecialCells(xlBlanks).Value = 0
 
Upvote 0
Many thanks for your help Fluff,

using your code, I have added the following, but it does not work, not sure why, could you please help? many thanks

Worksheets("sheet2").Range("D2:CU").SpecialCells(xlBlanks).Value = 0
 
Upvote 0
It should be D:CU not D2:CU
 
Upvote 0
Hello again,

is there any way to identify where the last row with values is? it is adding 0 up to row 1,048,576
 
Upvote 0
The code only works on the usedrange, so if it's putting 0s into all rows, you have some extraneous data or formatting somewhere in the row 1048576.
Select the rows below your data to the vary last row & delete them. Then save the file
You may also need to delete all the columns to the right of your data as well.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,164
Members
448,870
Latest member
max_pedreira

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