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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,452
Office Version
  1. 365
  2. 2021
  3. 2016
Platform
  1. Windows
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
 
Upvote 0

Forum statistics

Threads
1,186,826
Messages
5,960,019
Members
438,458
Latest member
manojkumarat1999

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