Find & replace hard-coded cells only

merry_fay

Board Regular
Joined
Oct 28, 2010
Messages
54
Hi,

I'm writing a macro to add new items to a list then copy down the formula from the row above. This far I'm fine, my problem is that the first few columns, depending on the month will be hard-coded & so I want to set these as 0 for the new item.

I have a month control, but in the instance someone has a blonde moment & sets it to the wrong one, any new items added would have the wrong number of columns of 0's & formulae.

Is there a way of doing a find & replace to find cells which could be any number & aren't formulae, then replacing them with a 0, or am I just looking at this completely the wrong way?

Thanks
merry_fay
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi. Try like this

Code:
ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants, xlNumbers).Value = 0
 
Upvote 0
Hi. Try like this

Code:
ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants, xlNumbers).Value = 0


This is great thanks, but I'm just having problems applying it to just the selected range & not the entire sheet. What does .UsedRange need to be changed to?

Thanks
merry_fay

Got there, need to change ActiveSheet.UsedRange to Selection.

THANKYOU :-)
 
Last edited:
Upvote 0
Try

Code:
Selection.SpecialCells(xlCellTypeConstants, xlNumbers).Value = 0
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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