macro run log

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
hi everyone - what ihave is a page called "log"

on this i need a two column table

in colA = date / time of macro run
in colB = successfull or failed - depending on if the macro finished or not

it must log and prepare for the next row or data entry the next time the macro is run

NOTE: the macro is singular i.e. one main macro to do everything in the service.

any ideas on how to get this done? :confused: :biggrin:
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,437
Hi

In your existing code, assuming you are using error handling, you would incorporate the result like this:

Code:
'Your existing variable declarations

Dim NextRow As Long
NextRow = Worksheets("log").Range("A65536").End(xlUp).Row + 1
Worksheets("log").Cells(NextRow, 1).Value = Format(Now(), "General Date")

On Error GoTo Error_Handler

'Your existing code
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
'  "      "      "
Worksheets("log").Cells(NextRow, 2).Value = "Successful"

Exit_Here:
    Exit Sub

Error_Handler:
    MsgBox Err.Description, vbCritical, "Error # " & Err.Number
    Worksheets("log").Cells(NextRow, 2).Value = "Failed"
    GoTo Exit_Here
    
End Sub

I don't expect you will be able to drop this code directly into your routine but hopefully it gets you started in the right direction.

Andrew
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,321
Messages
5,769,444
Members
425,546
Latest member
DisMissive

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
Top