how would i write this as a macro

sl1990

New Member
Joined
Jun 3, 2011
Messages
20
Hi how would i write this as a vba macro



if there is data in cell A3, search range B4:R4 for empty cells, if empty cells are found place the word "EMPTY" in T4. if there are no empty cells end macro.

if there is no data in cell A3 end macro




i know its a very easy question but i just cant get the hang of these macros !!

cheers
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Does it have to be a macro? This formula in T4 should do what you asked...

=IF(A3="","",IF(COUNTBLANK(B4:R4),"EMPTY",""))
 
Upvote 0
I over emphasized a little for instuctional purposes. There are a ton of different ways to do this like .specialcells but i think that this way might be the easiest for you to understand and remember.

Code:
Option Explicit
Sub Example()
Dim icell As Range
 
If Not IsEmpty(Sheets("Sheet1").Range("A3")) Then
    For Each icell In Range("B4:R4")
        If IsEmpty(icell) Then
            icell.Value = "Empty"
        Else
            'If it is not blank then nothing
        End If
    Next icell
Else
    'if A3 is blank then nothing
End If
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
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