Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 424
- Office Version
- 365
- Platform
- Windows
- Mobile
I need to list the names of my headers I`ve attempted to but no success?
Here is the Header loop. It shows blank?
Many Thanks in advance
End With
Here is the Header loop. It shows blank?
Many Thanks in advance
VBA Code:
For Each X In Rows(1).Cells
If X.Value = "" Then Exit For
Y = Y + 1
ReDim Preserve heading(i) As String
heading(Y) = X.Value
Next X
End With
VBA Code:
Sub vLookupAnotherWorkbook()
Dim Src As Workbook
Dim Des As Workbook
Dim SASheet As Worksheet
Dim PASheet As Worksheet
Dim MBefore As Integer
Dim MName As String
Dim ColNames As Object
Dim WSArray, i
ReDim WSArray(1 To Sheets.Count)
Dim heading() As String, X As Variant, Y as Variant
Dim LRow As Long
ReDim ColArray(1 To Columns.Count)
Dim FileToOpen As Variant
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
FileToOpen = ("\\DC01\Company\PURCHASING\Forecasting\Brett Martin Template for Vlookup.xlsm")
Workbooks.Open FileToOpen
Set Src = Workbooks("Brett Martin Template for Vlookup.xlsm")
Set Des = Workbooks("Brett Martin Forecast 2022.xlsm")
Set SASheet = Src.Sheets("Sales Analysis")
LRow = SASheet.Range("A1").CurrentRegion.Rows.Count
MBefore = Format(DateAdd("m", -1, Date), "mm")
MName = MonthName(MBefore)
With Des
For i = 1 To .Sheets.Count
WSArray(i) = .Sheets(i).Name
Next
End With
With SASheet
For Each X In Rows(1).Cells
If X.Value = "" Then Exit For
Y = Y + 1
ReDim Preserve heading(i) As String
heading(Y) = x.Value
Next x
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
' Workbooks("Src").Close _
' SaveChanges:=False
End Sub