![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 29
|
ia am trying to run a macro from a command botton only if there is any data in cell a1
here is my code that does not work Private Sub CommandButton1_Click() Dim ianswer As Integer If ("a1") Is Not Empty Then Run ("UploadToDatabaseWT062v8_800") ianswer = MsgBox("Upload OK", vbOKOnly) Else ianswer = MsgBox("There is no data to upload!", vbOKOnly) End If End Sub any hints? Thanks, W. |
|
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Perhaps the following will work:
Private Sub CommandButton1_Click() Dim ianswer As Integer If range("a1") <> "" Then Run ("UploadToDatabaseWT062v8_800") ianswer = MsgBox("Upload OK", vbOKOnly) Else ianswer = MsgBox("There is no data to upload!", vbOKOnly) End If End Sub Cheers, Nate [ This Message was edited by: NateO on 2002-02-21 08:03 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 29
|
Getting close,
Whether the cell is empty or not any code under this line If range("a1") <> "" Then runs |
|
|
|
|
|
#4 |
|
New Member
Join Date: Feb 2002
Posts: 29
|
My mistke! Your code works fine. Thanks for the help!
W. |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
That's my proposition. Getting close or hitting the nail on the head? Hopefully the latter.
Cheers, Nate |
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Nice! I think yours would too if you just inserted 'range' in front of your cell reference. Good hunting.
Cheers, Nate |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|