#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Code Help

There is one cell input I have that is disastrous if it is skipped. So, I'd
like my macro to go to that cell, then instruct the operator to choose from
a dropdown list already incorporated into that cell (via data, validation,
list) and then, after he has done that, click continue or Ok, so the macro
moves on. Can someone give me the code for this?

Thanks,
Grace


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Code Help

Hi
try something like the following:
sub foo()
with activesheet.range("A1")
if .value="" then
msgbox "Cell A1 has to be filled - Macro stopped"
exit sub
end if
end with
'now your code
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Grace wrote:
There is one cell input I have that is disastrous if it is skipped.
So, I'd like my macro to go to that cell, then instruct the operator
to choose from a dropdown list already incorporated into that cell
(via data, validation, list) and then, after he has done that, click
continue or Ok, so the macro moves on. Can someone give me the code
for this?

Thanks,
Grace

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Code Help

Dim TestCell as range
Set TestCell = sheet1.Range("G2") ' example

(...) ' your code

If CellEmpty(TestCell) Then Exit Sub

(...) ' your code



---------
Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then
CellEmpty = True
Target.Select
msgbox "Please Enter a value for the sekectted cell",,"Missing
Value"
Else
CellEmpty - False
End If
End Function



--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
There is one cell input I have that is disastrous if it is skipped. So,
I'd
like my macro to go to that cell, then instruct the operator to choose
from
a dropdown list already incorporated into that cell (via data, validation,
list) and then, after he has done that, click continue or Ok, so the macro
moves on. Can someone give me the code for this?

Thanks,
Grace




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Code Help

This looks great, Patrick. But when it compiles, it says "compile error:
Exit function Not allowed in sub or property". What am I doing wrong?

A couple of other clarifications:

When you wrote, CellEmpty - False, should it be " = False"

I was not as clear as I should have been. I'd actually like, as part of the
macro, for the user to choose a value for this cell, as the normal routine,
and then the subroutine would continue on its merry way. Can you add a
little more code that would do that?

Grace

"Patrick Molloy" wrote in message
...
Dim TestCell as range
Set TestCell = sheet1.Range("G2") ' example

(...) ' your code

If CellEmpty(TestCell) Then Exit Sub

(...) ' your code



---------
Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then
CellEmpty = True
Target.Select
msgbox "Please Enter a value for the sekectted cell",,"Missing
Value"
Else
CellEmpty - False
End If
End Function



--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
There is one cell input I have that is disastrous if it is skipped. So,
I'd
like my macro to go to that cell, then instruct the operator to choose
from
a dropdown list already incorporated into that cell (via data,

validation,
list) and then, after he has done that, click continue or Ok, so the

macro
moves on. Can someone give me the code for this?

Thanks,
Grace






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Code Help

Regarding only my very last clarification, I know realize that perhaps, it
already does allow you to enter something in that cell, while the macro is
running. I'm not sure! Also, I'm just not sure, once you do enter it, how
the macro knows to continue.

"Grace" wrote in message
...
This looks great, Patrick. But when it compiles, it says "compile error:
Exit function Not allowed in sub or property". What am I doing wrong?

A couple of other clarifications:

When you wrote, CellEmpty - False, should it be " = False"

I was not as clear as I should have been. I'd actually like, as part of

the
macro, for the user to choose a value for this cell, as the normal

routine,
and then the subroutine would continue on its merry way. Can you add a
little more code that would do that?

Grace

"Patrick Molloy" wrote in message
...
Dim TestCell as range
Set TestCell = sheet1.Range("G2") ' example

(...) ' your code

If CellEmpty(TestCell) Then Exit Sub

(...) ' your code



---------
Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then
CellEmpty = True
Target.Select
msgbox "Please Enter a value for the sekectted cell",,"Missing
Value"
Else
CellEmpty - False
End If
End Function



--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
There is one cell input I have that is disastrous if it is skipped.

So,
I'd
like my macro to go to that cell, then instruct the operator to choose
from
a dropdown list already incorporated into that cell (via data,

validation,
list) and then, after he has done that, click continue or Ok, so the

macro
moves on. Can someone give me the code for this?

Thanks,
Grace










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Code Help

you are correct

Else
CellEmpty - False
End If

should read
Else
CellEmpty = False
End If

Also, change the CellEmpty to

Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then

CellEmpty = NOT GetValue(Target)
Else

CellEmpty = False
End If
End Function


Function GetValue(Target as Range) as Boolean
Dim Entry as String
Entry = InputBox("Enter a value for selected cell")
If Entry ="" then
GetValue = False
Else
Target.Value = Entry
GetValue = True
End If
End Function


By now you'll see that I'm a great beleiver in procedural code....for a
start it makes it easier to understand and then it's a relatively easy
matter to make adjustments.


--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
Regarding only my very last clarification, I know realize that perhaps, it
already does allow you to enter something in that cell, while the macro is
running. I'm not sure! Also, I'm just not sure, once you do enter it,
how
the macro knows to continue.

"Grace" wrote in message
...
This looks great, Patrick. But when it compiles, it says "compile error:
Exit function Not allowed in sub or property". What am I doing wrong?

A couple of other clarifications:

When you wrote, CellEmpty - False, should it be " = False"

I was not as clear as I should have been. I'd actually like, as part of

the
macro, for the user to choose a value for this cell, as the normal

routine,
and then the subroutine would continue on its merry way. Can you add a
little more code that would do that?

Grace

"Patrick Molloy" wrote in message
...
Dim TestCell as range
Set TestCell = sheet1.Range("G2") ' example

(...) ' your code

If CellEmpty(TestCell) Then Exit Sub

(...) ' your code



---------
Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then
CellEmpty = True
Target.Select
msgbox "Please Enter a value for the sekectted
cell",,"Missing
Value"
Else
CellEmpty - False
End If
End Function



--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
There is one cell input I have that is disastrous if it is skipped.

So,
I'd
like my macro to go to that cell, then instruct the operator to
choose
from
a dropdown list already incorporated into that cell (via data,

validation,
list) and then, after he has done that, click continue or Ok, so the

macro
moves on. Can someone give me the code for this?

Thanks,
Grace










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Code Help

Ok, I got the functions copied into my macro, but I don't think you have
told me exactly how I call them from my subroutine.

Also, along those lines, I mentioned that the macro was rejecting the "end
function" statement you gave me earlier and I don't think you have addressed
that.

Thanks for a bit more help, Patrick!

Grace

"Patrick Molloy" wrote in message
...
you are correct

Else
CellEmpty - False
End If

should read
Else
CellEmpty = False
End If

Also, change the CellEmpty to

Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then

CellEmpty = NOT GetValue(Target)
Else

CellEmpty = False
End If
End Function


Function GetValue(Target as Range) as Boolean
Dim Entry as String
Entry = InputBox("Enter a value for selected cell")
If Entry ="" then
GetValue = False
Else
Target.Value = Entry
GetValue = True
End If
End Function


By now you'll see that I'm a great beleiver in procedural code....for a
start it makes it easier to understand and then it's a relatively easy
matter to make adjustments.


--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
Regarding only my very last clarification, I know realize that perhaps,

it
already does allow you to enter something in that cell, while the macro

is
running. I'm not sure! Also, I'm just not sure, once you do enter it,
how
the macro knows to continue.

"Grace" wrote in message
...
This looks great, Patrick. But when it compiles, it says "compile

error:
Exit function Not allowed in sub or property". What am I doing wrong?

A couple of other clarifications:

When you wrote, CellEmpty - False, should it be " = False"

I was not as clear as I should have been. I'd actually like, as part

of
the
macro, for the user to choose a value for this cell, as the normal

routine,
and then the subroutine would continue on its merry way. Can you add a
little more code that would do that?

Grace

"Patrick Molloy" wrote in message
...
Dim TestCell as range
Set TestCell = sheet1.Range("G2") ' example

(...) ' your code

If CellEmpty(TestCell) Then Exit Sub

(...) ' your code



---------
Function CellEmpty(Target as Range) as boolean
If Target.Value = "" then
CellEmpty = True
Target.Select
msgbox "Please Enter a value for the sekectted
cell",,"Missing
Value"
Else
CellEmpty - False
End If
End Function



--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"Grace" wrote in message
...
There is one cell input I have that is disastrous if it is skipped.

So,
I'd
like my macro to go to that cell, then instruct the operator to
choose
from
a dropdown list already incorporated into that cell (via data,
validation,
list) and then, after he has done that, click continue or Ok, so

the
macro
moves on. Can someone give me the code for this?

Thanks,
Grace












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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 10:12 AM.

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"