Macro jumbs to another macro without any reason

Joined
Jan 3, 2012
Messages
20
I have a Macro which earlier worked fine. Suddenly during execution it deletes all values to variables and jumps to a different macro. This happens at different places, when I problem search with steps F8. Anybody how have experienced this ? and preferable have a solution how to continue executing the macro I'm running.
Regards
Frank
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I have a Macro which earlier worked fine. Suddenly during execution it deletes all values to variables and jumps to a different macro. This happens at different places, when I problem search with steps F8. Anybody how have experienced this ? and preferable have a solution how to continue executing the macro I'm running.
Regards
Frank

to see your code would be the first step to troubleshoot
 
Upvote 0
to see your code would be the first step to troubleshoot

I was looking for a somebody who have experiensed the same problem. This macro used to work fine, no changes have been made to the module, no commands uses sub or likewiese, but here is the code:

______________________________________________________________________________________
Sub Kopier_til_fakturagrunnlag()
'
' Kopier_til_fakturagrunnlag Macro
' Kopierer aktuell kunde til fakturagrunnlaget.
'
Dim kundenr, kundenavn, adresse, poststed, k_ref, f_gr_lag, v_ref, f_dato, f_type, linjer
Dim rec_dato, rec_tog, rec_container, rec_k_ref, fra, til, pris, ekstra_loft, teu, rabatt
Dim avbestilling, farlig_gods, tillegg, linjenr, uke, belop, avd, mail

Windows("Faktura bilag John september 2014.xlsm").Activate
Sheets("Fakturabilag").Activate
kundenr = Cells(8, 4).Value
kundenavn = Cells(9, 4).Value
adresse = Cells(10, 4).Value
poststed = Cells(11, 4).Value
k_ref = Cells(12, 4).Value
f_gr_lag = Cells(13, 4).Value
mail = Cells(14, 4).Value
v_ref = Cells(8, 6).Value
uke = Cells(9, 6).Value
belop = Cells(10, 6).Value
f_dato = Cells(11, 6).Value
f_type = Cells(13, 6).Value


Range("Table1[[#Headers],[Faktura grunnlag]]").Select
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=19, Criteria1:= _
f_gr_lag

linjer = Cells(15, 1).Value

Workbooks.Open Filename:= _
"Y:\Booking\faktura bilag\ferdige grunnlag\Cargolink fakturagrunnlag bookingark.xltx" _
, Editable:=True
' ===========================================================================================
' ITS HERE IT JUMS TO A DIFFERENT MACRO. WHEN I DROP THE ACTUALS LINES IT JUMPS AT THE NEXT LINE
' ===========================================================================================

ActiveWorkbook.SaveAs Filename:="y:\Booking\faktura bilag\ferdige grunnlag\" & f_gr_lag & ".xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Windows("Cargolink fakturagrunnlag bookingark.xltx").Activate
Sheets("Fakturagr").Activate
Cells(12, 8) = kundenr
Cells(9, 8) = f_type
Cells(15, 3) = kundenavn
Cells(16, 3) = adresse
Cells(17, 3) = poststed
Cells(20, 5) = f_gr_lag
Cells(22, 5) = k_ref
Cells(22, 14) = v_ref
Cells(14, 16) = f_dato
Cells(16, 16) = f_dato
Cells(18, 16) = avd
Cells(20, 16) = " MV "

Windows("Faktura bilag John september 2014.xlsm").Activate
Sheets("Fakturabilag").Activate

Cells(4950, 3).Select
Range(Selection, Selection.End(xlUp)).Select
linjenr = ActiveCell.Row
tog = Cells(linjenr, 3).Value
Sheets("TogNr").Activate
Cells(1, 11) = tog
avd = Cells(1, 12).Value
fra = Cells(1, 13).Value
til = Cells(1, 14).Value


Windows(f_gr_lag & ".xlsx").Activate


Cells(18, 16) = avd
Cells(25, 4) = "Frakt uke " & uke

Cells(27, 4) = "Strekningen " & fra & " " & til


Cells(32, 1).Activate
Cells(32, 2) = avd
Cells(32, 4) = "Containerfrakt"
Cells(32, 12) = 1
Cells(32, 16) = belop
Cells(52, 4) = mail

ActiveWorkbook.SaveAs Filename:= _
"S:\Booking\faktura bilag\ferdige grunnlag\" & f_gr_lag & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False

End Sub

________________________________________________________________________________________

I have marked to place where the jump occurs with ==================.

Regards
Frank
 
Upvote 0
I was looking for a somebody who have experiensed the same problem. This macro used to work fine, no changes have been made to the module, no commands uses sub or likewiese, but here is the code:

______________________________________________________________________________________
Sub Kopier_til_fakturagrunnlag()
'
' Kopier_til_fakturagrunnlag Macro
' Kopierer aktuell kunde til fakturagrunnlaget.
'
Dim kundenr, kundenavn, adresse, poststed, k_ref, f_gr_lag, v_ref, f_dato, f_type, linjer
Dim rec_dato, rec_tog, rec_container, rec_k_ref, fra, til, pris, ekstra_loft, teu, rabatt
Dim avbestilling, farlig_gods, tillegg, linjenr, uke, belop, avd, mail

Windows("Faktura bilag John september 2014.xlsm").Activate
Sheets("Fakturabilag").Activate
kundenr = Cells(8, 4).Value
kundenavn = Cells(9, 4).Value
adresse = Cells(10, 4).Value
poststed = Cells(11, 4).Value
k_ref = Cells(12, 4).Value
f_gr_lag = Cells(13, 4).Value
mail = Cells(14, 4).Value
v_ref = Cells(8, 6).Value
uke = Cells(9, 6).Value
belop = Cells(10, 6).Value
f_dato = Cells(11, 6).Value
f_type = Cells(13, 6).Value


Range("Table1[[#Headers],[Faktura grunnlag]]").Select
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=19, Criteria1:= _
f_gr_lag

linjer = Cells(15, 1).Value

Workbooks.Open Filename:= _
"Y:\Booking\faktura bilag\ferdige grunnlag\Cargolink fakturagrunnlag bookingark.xltx" _
, Editable:=True
' ===========================================================================================
' ITS HERE IT JUMS TO A DIFFERENT MACRO. WHEN I DROP THE ACTUALS LINES IT JUMPS AT THE NEXT LINE
' ===========================================================================================

ActiveWorkbook.SaveAs Filename:="y:\Booking\faktura bilag\ferdige grunnlag\" & f_gr_lag & ".xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

Windows("Cargolink fakturagrunnlag bookingark.xltx").Activate
Sheets("Fakturagr").Activate
Cells(12, 8) = kundenr
Cells(9, 8) = f_type
Cells(15, 3) = kundenavn
Cells(16, 3) = adresse
Cells(17, 3) = poststed
Cells(20, 5) = f_gr_lag
Cells(22, 5) = k_ref
Cells(22, 14) = v_ref
Cells(14, 16) = f_dato
Cells(16, 16) = f_dato
Cells(18, 16) = avd
Cells(20, 16) = " MV "

Windows("Faktura bilag John september 2014.xlsm").Activate
Sheets("Fakturabilag").Activate

Cells(4950, 3).Select
Range(Selection, Selection.End(xlUp)).Select
linjenr = ActiveCell.Row
tog = Cells(linjenr, 3).Value
Sheets("TogNr").Activate
Cells(1, 11) = tog
avd = Cells(1, 12).Value
fra = Cells(1, 13).Value
til = Cells(1, 14).Value


Windows(f_gr_lag & ".xlsx").Activate


Cells(18, 16) = avd
Cells(25, 4) = "Frakt uke " & uke

Cells(27, 4) = "Strekningen " & fra & " " & til


Cells(32, 1).Activate
Cells(32, 2) = avd
Cells(32, 4) = "Containerfrakt"
Cells(32, 12) = 1
Cells(32, 16) = belop
Cells(52, 4) = mail

ActiveWorkbook.SaveAs Filename:= _
"S:\Booking\faktura bilag\ferdige grunnlag\" & f_gr_lag & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False

End Sub

________________________________________________________________________________________

I have marked to place where the jump occurs with ==================.

Regards
Frank

is there any macro defined in Y:\Booking\faktura bilag\ferdige grunnlag\Cargolink fakturagrunnlag bookingark.xltx workbook?
 
Upvote 0
is there any macro defined in Y:\Booking\faktura bilag\ferdige grunnlag\Cargolink fakturagrunnlag bookingark.xltx workbook?

Hippiehacker

Thanks for your help. This was the problem, I renamed this workbook just in the linen before, then trying to activate the workbook which isn't open send the macro back to it origin, and then stopped.

Regards
Frank
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top