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
 
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.

Thank you Fluff.
I have deleted everything below the data (in case there was something), but It is still filling with 0 up to row 1,048,576, it takes a lot of memory, I have values up to row 2,000. Could you please help?
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Ok, how about
Code:
Sub RoseChapman()
   Range("D1:CU" & Range("[COLOR=#ff0000]A[/COLOR]" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).Value = 0
End Sub
Change the A in red to any column that will have data in the last row.
 
Upvote 0
Thank you Fluff
it does not work, I have added the below to my code

Worksheets("sheet2").Range("D:CU" & Range("CU" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).Value = 0
 
Upvote 0
You're missing the row number after ("D1:
Also as you're working on a nonactive sheet you will need to qualify the 2nd Range as well.
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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