ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   userform commnad from a sheet command (https://www.excelbanter.com/excel-discussion-misc-queries/208064-userform-commnad-sheet-command.html)

teepee[_3_]

userform commnad from a sheet command
 
Hello

I have the following piece of code in Excel sheet 1 to trigger an event when
a cell content changes

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$4" Then
'This Code Runs When Cell A4 Changes'
End If
End Sub

What I want to do is insert here code to interrupt the running of a
particular userform and goto a particular point and resume that same
userform.

So something like

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$4" Then
userform1.stop
goto userform 1line 220
userform1.resume
End If
End Sub

Except obviously I'm making up the code here. Could anyone advise on what
the correct code might be for such an operation.

Many thanks




ShaneDevenshire

userform commnad from a sheet command
 
Hi,

We would generally not use a branch for this (Go To Line) more likely

If x = "Y" then
FirstSub
Else
SecondSub
End If

Where FirstSub is the name of a separate subroutine and SecondSub another
name.
But if you must use the method you mentions

If x="Y" then
Go To MyLine
End if


MyLine: (this is a line number in excel)
your code here

--
Thanks,
Shane Devenshire


"teepee" wrote:

Hello

I have the following piece of code in Excel sheet 1 to trigger an event when
a cell content changes

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$4" Then
'This Code Runs When Cell A4 Changes'
End If
End Sub

What I want to do is insert here code to interrupt the running of a
particular userform and goto a particular point and resume that same
userform.

So something like

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$4" Then
userform1.stop
goto userform 1line 220
userform1.resume
End If
End Sub

Except obviously I'm making up the code here. Could anyone advise on what
the correct code might be for such an operation.

Many thanks





teepee[_3_]

userform commnad from a sheet command
 
Many thanks




All times are GMT +1. The time now is 03:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com