How do you program "do this to the range of cells selec

colmmc

Board Regular
Joined
Jan 8, 2004
Messages
59
.....into a macro? It's probably really obvious but I cant work it out.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Re: How do you program "do this to the range of cells s

Apologies for the messed up title.

I'm trying to set up some text cleaning macros that can be applied to any rance of cells but I dont know how to get it progammed to be applied to any range selected. I need it to be flexible so that I can clean up various sized tables.
 
Upvote 0
Re: How do you program "do this to the range of cells s

Will the "selection" statement do? It works on whichever cells are currently selected.
E.g.

With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
 
Upvote 0
Re: How do you program "do this to the range of cells s

Hello,

This will clear the contents of the selected cells

Code:
Sub do_this()
With Selection
 .ClearContents
End With
End Sub
 
Upvote 0
I'm not clearing contents, I'm cleaning up the data, removing trainling spaces, removing underscore, separating text, etc.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,207,438
Messages
6,078,561
Members
446,349
Latest member
Malroos7912

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