Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Want to check if cell is blank before running macro

I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error message
if the cell is blank. How do I do that?



Sheets("REQUEST ").Select
ActiveSheet.Unprotect
Rows("4:4").Select
Selection.Insert Shift:=xlDown
Application.Goto Reference:="NewRecord"
Selection.Copy
Rows("4:4").Select
ActiveSheet.Paste
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Range("D4").Select
Sheets("SEARCH ").Select
Range("D9:E9").Select
Application.CutCopyMode = False
  #2   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default Want to check if cell is blank before running macro


Sub test()
If IsEmpty([d4]) Then _
Err.Raise 1000, , "Your error"

End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


"Munchkin" wrote:

I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error message
if the cell is blank. How do I do that?



Sheets("REQUEST ").Select
ActiveSheet.Unprotect
Rows("4:4").Select
Selection.Insert Shift:=xlDown
Application.Goto Reference:="NewRecord"
Selection.Copy
Rows("4:4").Select
ActiveSheet.Paste
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Range("D4").Select
Sheets("SEARCH ").Select
Range("D9:E9").Select
Application.CutCopyMode = False

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Want to check if cell is blank before running macro

On 3 Giu, 22:34, Munchkin wrote:
I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error message
if the cell is blank. *How do I do that?

Sheets("REQUEST ").Select
* * ActiveSheet.Unprotect
* * Rows("4:4").Select
* * Selection.Insert Shift:=xlDown
* * Application.Goto Reference:="NewRecord"
* * Selection.Copy
* * Rows("4:4").Select
* * ActiveSheet.Paste
* * Range("A4").Select
* * Application.CutCopyMode = False
* * Selection.Copy
* * Range("D4").Select
* * Sheets("SEARCH ").Select
* * Range("D9:E9").Select
* * Application.CutCopyMode = False


Hi Munchin.
the macro part is quite incomprehensible; however you can use:

........
If Range("D4").Value = "" then
' make something
Else
' make something else
End If
.......

Regards
Eliano
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Want to check if cell is blank before running macro

Without seeing all, try these ideas

with Sheets("REQUEST ")
If Len(Application.Trim(.Range("d4"))) < 1 Then
MsgBox "bad"
Exit Sub
End If
'MsgBox "go on "

.Unprotect

.Rows("4).insert

range("NewRecord").copy .cells(4,"a")
'etc
Sheets("SEARCH ").Range("D9:E9").copy ' ??

end with
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Munchkin" wrote in message
...
I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error
message
if the cell is blank. How do I do that?



Sheets("REQUEST ").Select
ActiveSheet.Unprotect
Rows("4:4").Select
Selection.Insert Shift:=xlDown
Application.Goto Reference:="NewRecord"
Selection.Copy
Rows("4:4").Select
ActiveSheet.Paste
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Range("D4").Select
Sheets("SEARCH ").Select
Range("D9:E9").Select
Application.CutCopyMode = False


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Want to check if cell is blank before running macro

On 3 Giu, 22:34, Munchkin wrote:
I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error message
if the cell is blank. *How do I do that?

Sheets("REQUEST ").Select
* * ActiveSheet.Unprotect
* * Rows("4:4").Select
* * Selection.Insert Shift:=xlDown
* * Application.Goto Reference:="NewRecord"
* * Selection.Copy
* * Rows("4:4").Select
* * ActiveSheet.Paste
* * Range("A4").Select
* * Application.CutCopyMode = False
* * Selection.Copy
* * Range("D4").Select
* * Sheets("SEARCH ").Select
* * Range("D9:E9").Select
* * Application.CutCopyMode = False


Hi Munchin.
the macro part is quite incomprehensible; however you can use:

........
If Range("D4").Value = "" then
' make something
Else
' make something else
End If
.......

Regards
Eliano


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Want to check if cell is blank before running macro

Without seeing all, try these ideas

with Sheets("REQUEST ")
If Len(Application.Trim(.Range("d4"))) < 1 Then
MsgBox "bad"
Exit Sub
End If
'MsgBox "go on "

.Unprotect

.Rows("4).insert

range("NewRecord").copy .cells(4,"a")
'etc
Sheets("SEARCH ").Range("D9:E9").copy ' ??

end with
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Munchkin" wrote in message
...
I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error
message
if the cell is blank. How do I do that?



Sheets("REQUEST ").Select
ActiveSheet.Unprotect
Rows("4:4").Select
Selection.Insert Shift:=xlDown
Application.Goto Reference:="NewRecord"
Selection.Copy
Rows("4:4").Select
ActiveSheet.Paste
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Range("D4").Select
Sheets("SEARCH ").Select
Range("D9:E9").Select
Application.CutCopyMode = False


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clearing Check Boxes & Running a diff Macro when unchecking the ch Vick Excel Discussion (Misc queries) 6 May 30th 07 08:44 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Excel Programming 4 April 12th 07 08:56 PM
Check values before running macro Dan R. Excel Programming 9 February 8th 07 04:54 PM
How to check a cell for content before running macro. Incoherent Excel Programming 1 October 7th 05 04:42 PM
Check cell for data before running code Pat Excel Programming 1 January 12th 05 08:58 PM


All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"