Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default GoTo problem.

I'm not very familiar with Excel but managed to construct this:
Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
If Range("B5") <= 4 Then
Range("C5") = Null
End If

If Range("B5") 4 Then
MsgBox "Density is required!"
End If

End Sub

I want the cursor to go to cell C5 after clearing the message box
however I can't seem to work that out. I know GoTo is the right
command but I keep sending the debugger into fits.

Also, once the cursor is in C5 and If B5 is 4 I don't want the user
to be able to exit C5 until a value is entered. How can I do that?

Thanks for your help!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default GoTo problem.

Right click on sheet name | click view code
Paste the below code


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address < "$B$5" Then Exit Sub

If Target.Value <= 4 Then
Target.Offset(0, 1).Value = Clear
End If

first:
If Target.Value 4 And Target.Offset(0, 1).Value = "" Then
Target.Offset(0, 1).Select
ans = InputBox("Density Required", "Enter Value in CELL C5")
If ans = "" Then GoTo first
Target.Offset(0, 1).Value = ans
End If

End Sub


On Oct 23, 5:58*pm, johnlute wrote:
I'm not very familiar with Excel but managed to construct this:
Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
* If Range("B5") <= 4 Then
* *Range("C5") = Null
* End If

* If Range("B5") 4 Then
* * MsgBox "Density is required!"
* End If

End Sub

I want the cursor to go to cell C5 after clearing the message box
however I can't seem to work that out. I know GoTo is the right
command but I keep sending the debugger into fits.

Also, once the cursor is in C5 and If B5 is 4 I don't want the user
to be able to exit C5 until a value is entered. How can I do that?

Thanks for your help!!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default GoTo problem.


Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
If Range("B5") <= 4 Then
Range("C5") = ""
End If

If Range("B5") 4 Then
MsgBox "Density is required!"
Range("C5").Select
End If
End Sub

you can use the sheet's selection_change event to keep C5 selected

right click the sheet's tab and select view code, then paste this:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C5") = "" And Range("B5") 4 Then
Range("C5").Select
End If
End Sub



"johnlute" wrote:

I'm not very familiar with Excel but managed to construct this:
Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
If Range("B5") <= 4 Then
Range("C5") = Null
End If

If Range("B5") 4 Then
MsgBox "Density is required!"
End If

End Sub

I want the cursor to go to cell C5 after clearing the message box
however I can't seem to work that out. I know GoTo is the right
command but I keep sending the debugger into fits.

Also, once the cursor is in C5 and If B5 is 4 I don't want the user
to be able to exit C5 until a value is entered. How can I do that?

Thanks for your help!!!
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default GoTo problem.

Thanks, Patrick!!!

On Oct 23, 10:45*am, Patrick Molloy
wrote:
Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
* If Range("B5") <= 4 Then
* *Range("C5") = ""
* End If

* If Range("B5") 4 Then
* * MsgBox "Density is required!"
* *Range("C5").Select
* End If
End Sub

you can use the sheet's selection_change event to keep C5 selected

right click the sheet's tab and select view code, then paste this:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* * If Range("C5") = "" And Range("B5") 4 Then
* * * * Range("C5").Select
* * End If
End Sub



"johnlute" wrote:
I'm not very familiar with Excel but managed to construct this:
Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
* If Range("B5") <= 4 Then
* *Range("C5") = Null
* End If


* If Range("B5") 4 Then
* * MsgBox "Density is required!"
* End If


End Sub


I want the cursor to go to cell C5 after clearing the message box
however I can't seem to work that out. I know GoTo is the right
command but I keep sending the debugger into fits.


Also, once the cursor is in C5 and If B5 is 4 I don't want the user
to be able to exit C5 until a value is entered. How can I do that?


Thanks for your help!!!
.- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default GoTo problem.

Thanks, muddan!!!

On Oct 23, 10:30*am, muddan madhu wrote:
Right click on sheet name | click view code
Paste the below code

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address < "$B$5" Then Exit Sub

If Target.Value <= 4 Then
* * * Target.Offset(0, 1).Value = Clear
End If

first:
If Target.Value 4 And Target.Offset(0, 1).Value = "" Then
* * Target.Offset(0, 1).Select
* * * * ans = InputBox("Density Required", "Enter Value in CELL C5")
* * * * * * * *If ans = "" Then GoTo first
* * * * * * *Target.Offset(0, 1).Value = ans
End If

End Sub

On Oct 23, 5:58*pm, johnlute wrote:



I'm not very familiar with Excel but managed to construct this:
Sub DDUOM_Change()
' DDUOM_Change Macro
' Macro recorded 10/22/2009 by jlute
* If Range("B5") <= 4 Then
* *Range("C5") = Null
* End If


* If Range("B5") 4 Then
* * MsgBox "Density is required!"
* End If


End Sub


I want the cursor to go to cell C5 after clearing the message box
however I can't seem to work that out. I know GoTo is the right
command but I keep sending the debugger into fits.


Also, once the cursor is in C5 and If B5 is 4 I don't want the user
to be able to exit C5 until a value is entered. How can I do that?


Thanks for your help!!!- Hide quoted text -


- Show quoted text -


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
On error goto problem Coppercrutch Excel Discussion (Misc queries) 3 December 28th 07 03:04 PM
"On Error GoTo" syntax problem jonrayworth Excel Programming 1 July 1st 06 01:16 AM
Find then GoTo problem code ufo_pilot Excel Programming 4 December 19th 05 05:40 PM
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM


All times are GMT +1. The time now is 04:02 AM.

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

About Us

"It's about Microsoft Excel"