Macro is not removing cells correctly from a form control button

shyy

Well-known Member
Joined
Nov 6, 2008
Messages
1,484
Hey everyone,

I have this macro where if I run it, it will work. However when I run it from my form, it doesn't work. What I want to do is select the active row and delete cells that don't have a formula.

When I run the macro within my form, it deletes all the cells, but when I run the macro without opening the form, it seems to always work. Anyone know why? Thanks in advance

Code:
    Range("D" & ActiveCell.Row & ":Z" & ActiveCell.Row).Select
    Selection.SpecialCells(xlCellTypeConstants).Select
    Selection.ClearContents
 
The cells with formulas are they still showing?

I want them to stay intact, only cells that don't have a formula to be deleted. Is it doing that for you?

What do you mean by constant?

Thanks
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hmm this is strange, don't know why its working for you. Everything on the row gets deleted when I run it from the form, but when I run the macro without the form opened, it works fine, all the constants are moved and the cells with formulas are not deleted.
 
Upvote 0
I just steped through in vba, and it doesn't pick up the constants.

Is there an alternative to use this code?

Selection.SpecialCells(xlCellTypeConstants).Select
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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