Need Help for the Macro What i have prepared

srinayana

Board Regular
Joined
Dec 22, 2008
Messages
84
Hi ,


Please find the script below what i have written

Public Function BlankCells_Filler() As Integer
ActiveSheet.Unprotect
ActiveSheet.Range("A" & 65536).Select
Selection.End(xlUp).Select
last_data_row = ActiveCell.Row
Range(ActiveCell, ActiveCell.End(xlUp)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "N/A"
Range("A16").Select
ActiveWorkbook.Save
End Function



I want to make some changes to the macro. So i need your help.

What i want .

1) Macro Should work only if "A16" is not Blank.So If A16 is Blank then this macro should not work.(Macro should end without any changes).

2) I Want to select the Row upto Column "AZ" even thought the cell is blank.But in the script("Range(Selection, Selection.End(xlToRight)).Select") what i have written it selects last Active Cell.

Please do me the need ful

Thanks in Advance


 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This will select from A1 to AZ down to the used rows in column A.

So if column A has data to row 40
The selection will be

A1:AZ40

Change A1 in below code to the "from" place to select.

Code:
ActiveSheet.Unprotect


    If Range("A16") = "" Then

    Msgbox "A16 is blank - we do nothing"
    
    Else
    
    lr = ActiveSheet.Range("A65536").End(xlUp).Row
    lrw = "AZ" & lr
    
    Range("A1:" & lrw).Select
    
    Selection.FormulaR1C1 = "N/A"
    Range("A16").Select
    ActiveWorkbook.Save
    End If
 
Last edited:
Upvote 0
This will select from A1 to AZ down to the used rows in column A.

So if column A has data to row 40
The selection will be

A1:AZ40

Change A1 in below code to the "from" place to select.

Code:
ActiveSheet.Unprotect
 
 
    If Range("A16") = "" Then
 
    Msgbox "A16 is blank - we do nothing"
 
    Else
 
    lr = ActiveSheet.Range("A65536").End(xlUp).Row
    lrw = "AZ" & lr
 
    Range("A1:" & lrw).Select
 
    Selection.FormulaR1C1 = "N/A"
    Range("A16").Select
    ActiveWorkbook.Save
    End If

Hi Shyrath,


Thank You very much.

Its working for me.

Thank you once again for your support
 
Upvote 0

Forum statistics

Threads
1,203,491
Messages
6,055,727
Members
444,814
Latest member
AutomateDifficulty

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