macro only run if cell is not empty

G

Guest

i have a macro thats copy a row to a worksheet. To make it perfect i want
that the macro looks if for example Cell A 5 in that row is not empty. If its
not empty run de macro thats copy the row to a worksheet. If its not empty
that the user got an error windows for example: A5 is empty Macro do not work.

is this possible...?

greetings.
 
R

R.VENKATARAMAN

try this

Public Sub test()
If Range("A5") <> "" Then
(macro name)
Else
MsgBox "A5 is empty Macro does not work."


End If
End Sub
 
G

Guest

If Range("A5") = Empty Then
MsgBox "Cell A5 is empty!"
Else
Call copymacro_name
End If


Regards,
Stefi

„Pieter†ezt írta:
 
G

Guest

thanks for the quick response but
this is only working when cell A5 is empty.
it must also work when i want to run de macro on row 150 for example.
so then A 150 the macro had to check if its empty or not.

gr.
 
G

Guest

If Range("A" & ActiveCell.Row) = Empty Then
MsgBox "Cell A5 is empty!"
Else
Call copymacro_name
End If

Regards,
Stefi

„Pieter†ezt írta:
 
G

Guest

Perfect this is exactly what i want...

thanks

Stefi said:
If Range("A" & ActiveCell.Row) = Empty Then
MsgBox "Cell A5 is empty!"
Else
Call copymacro_name
End If

Regards,
Stefi

„Pieter†ezt írta:
 
G

Guest

You are welcome! Thanks for the feedback!
Regards,
Stefi


„Pieter†ezt írta:
 
Joined
Feb 22, 2022
Messages
1
Reaction score
0
Sub abc()
'


' abc Macro
'

'
If Worksheets("SHEET1").Cells("C10,C13").Value = "" Then
MsgBox "data NOT save"
End If

Range("C10:C13").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Rows("3:3").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B6").Select
Sheets("Sheet1").Select
Range("C10:C13").Select
Selection.ClearContents
Range("C10").Select
MsgBox "data save"


End Sub

HI EVERYONE
THIS Macro not run
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top