Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
Please consider this code ...
On workbook Open ...
I am getting a "Variable not defined" error with the object highlighted in the code below.
I have declared wb_main as public in the workbook declarations, and set it in the workbook open module. But it appears to not have carried over.
On workbook Open ...
Code:
Option Explicit
Public wb_main As Workbook
Public ws_anraw As Worksheet
Public ws_anwork As Worksheet
Public rpt_date As Date
Private Sub Workbook_Open()
Stop
Dim wscnt As Integer
Dim i As Integer
Set wb_main = Workbooks("Data.xlsm")
wscnt = ActiveWorkbook.Worksheets.Count
For i = wscnt To 1 Step -1
If Worksheets(i).Name = "Sheet1" Then
Application.DisplayAlerts = False
wb_main.Worksheets(i).Delete
Application.DisplayAlerts = True
End If
Next i
Set ws_anwork = wb_main.Worksheets("ACTIVE_WORKING")
transfer_raw
End Sub
I am getting a "Variable not defined" error with the object highlighted in the code below.
Rich (BB code):
Sub transfer_raw()
Dim wbnum As Long
Dim wb As Workbook
Dim ws As Worksheet
wbnum = 0
For Each wb In Workbooks
wbnum = wbnum + 1
Next wb
Stop
If wbnum < 2 Then
MsgBox "There are no raw ActiveNet workbooks open."
Else
MsgBox "There are " & wbnum & " open worksheets."
For Each wb In Workbooks
If wb.Name Like "active_report*" Then
Workbooks(wb.Name).Worksheets("Sheet1").Copy Before:=wb_main.Worksheets("PERMITS")
Stop
Set ws_anraw = wb_main.Worksheets("Sheet1")
cleanData
End If
Next wb
End If
End Sub
I have declared wb_main as public in the workbook declarations, and set it in the workbook open module. But it appears to not have carried over.