replace cell contents in range

KyleG

Well-known Member
Joined
Jun 12, 2004
Messages
629
Office Version
  1. 365
Platform
  1. Windows
I need to have a macro that looks down the A column for the last cell with data (Upto A1800 have formula that displays nothing unless condition meet on another page). This will form the last row of the area that the replace formula acts in. Lets call it LR
Like wise it needs to look across the 1 column for the last column with data This forms the last column for the replace formula. Lets call it LC.
Then all cells in the range B3:to LC-LR that are blank get an x.

Can anyone help please. Thanks in advance
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
KyleG,

If I understand you correctly.


Before the macro:


Excel Workbook
ABCDEFGH
3333
4444
5555
6666
7777
8888
9999
10101010
11111111
12121212
13131313
14141414
15151515
16161616
17171717
18181818
19191919
20202020
21212121
22222222
23
Sheet1



After the macro:


Excel Workbook
ABCDEFGH
33x3xxx3
44x4xxx4
55x5xxx5
66x6xxx6
77x7xxx7
88x8xxx8
99x9xxx9
1010x10xxx10
1111x11xxx11
1212xxx12x12
1313xxx13x13
1414xxx14x14
1515xxx15x15
1616xxx16x16
1717xxx17x17
1818xxx18x18
1919xxx19x19
2020xxx20x20
2121xxx21x21
2222xxx22x22
23
Sheet1




Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Press and hold down the 'ALT' key, and press the 'F11' key.

On the 'Insert' menu, click 'Module'.

Copy the below code, and paste it into the Module (on the right pane).


Code:
Option Explicit
Sub Put_x_inBlankCells()
Dim LR As Long, LC As Long
Application.ScreenUpdating = False
With ActiveSheet
  LR = .Range("A3").End(xlDown).Row
  LC = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
  .Range(Cells(3, 2), Cells(LR, LC)).SpecialCells(xlCellTypeBlanks) = "x"
End With
Application.ScreenUpdating = True
End Sub


Then run the "Put_x_inBlankCells" macro.


Have a great day,
Stan
 
Last edited:
Upvote 0

Forum statistics

Threads
1,222,437
Messages
6,166,025
Members
452,008
Latest member
Customlogoflipflops

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