Hello,
I need to call from Macro1 in Module 1 the "Private Sub Worksheet_Change(ByVal Target As Range)".
I tried with:
Application.Run "Sheet1.Worksheet_Change"
but it doesn't work.
Any help?
Thanks!
Hello,
I need to call from Macro1 in Module 1 the "Private Sub Worksheet_Change(ByVal Target As Range)".
I tried with:
Application.Run "Sheet1.Worksheet_Change"
but it doesn't work.
Any help?
Thanks!
Put your code in a separate subroutine. Call that subroutine from both the worksheet change event, and from Macro 1.
e.g.
![]()
Private Sub Worksheet_Change(ByVal Target As Range) Call foo End Sub Sub foo() 'your code here Debug.Print "foo happened" End Sub Sub Macro1() Call foo End Sub
let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source
If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE
Walking the tightrope between genius and eejit...
This is not possible.I need to call from Macro1 in Module 1 the "Private Sub Worksheet_Change(ByVal Target As Range)".
post your Worksheet change code so that helpers can change it to work in a module.
Click the * Add Reputation below to say thanks.
![]()
Private Sub Worksheet_Change(ByVal Target As Range) Call macro1 End Sub
Happy with my answer * Add Reputation.
If You are happy with solution, please use Thread tools and mark thread as SOLVED.
When I read the question I think TS wants the opposite.
this is not possible![]()
Sub macro1 Call Worksheet_Change end sub
Hello,
well, Macro 1 checks if all the column headers have an expected value "string".
If not, an error MsgBox is shown.
If an error is found I want to give the user to correct the wrong column header name.
I can do it withbut this doesn't allow the user to type on the Sheet.![]()
Application.wait
The best solution would be:
- Error Found
- MsgBox Shown
- Let the user type on the Sheet to correct the mistake
- The Worksheet "recognize" the Change through- The check routine (![]()
Private Sub Worksheet_Change(ByVal Target As Range)
) is performed again.![]()
Go to ControllaColonne
Thanks!![]()
Sub Macro1() Dim ArrayTitoli(13) As String Dim Result As Integer ' Declare Array with correct column headers ArrayTitoli(0) = "Anno Stagione" ArrayTitoli(1) = "Tema" ArrayTitoli(2) = "Fase di Nascita cod" ArrayTitoli(3) = "Classe" ArrayTitoli(4) = "Articolo" ArrayTitoli(5) = "Colore" ArrayTitoli(6) = "Quantità" ArrayTitoli(7) = "0 - DA RICEVERE" ArrayTitoli(8) = "1 - DA LANCIARE" ArrayTitoli(9) = "2 - TAGLIO" ArrayTitoli(10) = "3 - PREPARAZIONE" ArrayTitoli(11) = "4 - ASSEMBLAGGIO" ArrayTitoli(12) = "5 - RIFINITURE" ArrayTitoli(13) = "CHIUSE" ControllaColonne: For i = 0 To 13 With Range("A1") If .Offset(0, i) <> ArrayTitoli(i) Then Result = MsgBox("Verificare che i titoli corrispondano all'estrazione corretta." _ & Chr(13) & "L'ordine corretto è il seguente:" _ & Chr(13) & "" _ & Chr(13) & "Anno Stagione" _ & Chr(13) & "Tema" _ & Chr(13) & "Fase di Nascita cod" _ & Chr(13) & "Classe" _ & Chr(13) & "Articolo" _ & Chr(13) & "Colore" _ & Chr(13) & "Quantità" _ & Chr(13) & "0 - DA RICEVERE" _ & Chr(13) & "1 - DA LANCIARE" _ & Chr(13) & "2 - TAGLIO" _ & Chr(13) & "3 - PREPARAZIONE" _ & Chr(13) & "4 - ASSEMBLAGGIO" _ & Chr(13) & "5 - RIFINITURE" _ & Chr(13) & "CHIUSE" _ & Chr(13) _ & Chr(13) & "Errore nell colonna: " & i + 1 & ".", vbCritical, "Colonne non Corrispondenti") End If End With Next ' ****PROBLEM**** If Result > 0 Then Application.Run "Sheet1.Worksheet_Change", Range("A1") 'Application.Wait (Now + TimeValue("0:00:10")) 'GoTo ControllaColonne End If End Sub
Try this
![]()
Sub Test() Application.Run "Sheet1.Worksheet_Change", Range("A1") End Sub
< ----- Please click the little star * next to add reputation if my post helps you
Visit Forum : From Here
I think it will be useful if you attached a sample workbook ...
BrianAll,
Try something like
Change a1 to suite if needed.![]()
Run "sheet1.worksheet_change", Sheet1.Range("a1")
Last edited by jindon; 02-06-2019 at 01:23 AM.
It works!
Thanks jindon
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks