dahveedoff
New Member
- Joined
- Jan 31, 2014
- Messages
- 7
Hi Guys,
Newbie to VBA!!
I need to loop through worksheets in a workbook and copy every first cell value(A1) and then paste into a new worksheet.
I have tried various loops. some have copied first value for the first sheet and then pasted in the new sheet. while others have been not so good.
This is the code I have so far and this does not work at all.
Please help out
Newbie to VBA!!
I need to loop through worksheets in a workbook and copy every first cell value(A1) and then paste into a new worksheet.
I have tried various loops. some have copied first value for the first sheet and then pasted in the new sheet. while others have been not so good.
This is the code I have so far and this does not work at all.
Code:
Sub Check()
Dim ws As Worksheet
Dim lr As Long
Dim treg As Worksheet
Dim wok As Workbook
Dim i As Long
Dim j As Long
Dim n As Integer
Sheets("Dashboard").Visible = xlSheetVeryHidden
Sheets("RAW DATA").Visible = xlSheetVeryHidden
Sheets("Master").Visible = xlSheetVeryHidden
Set wok = ActiveWorkbook
Set treg = wok.Worksheets.Add(After:=wok.Worksheets(wok.Worksheets.Count))
treg.Name = "Summary"
For Each ws In wok.Worksheets
If ws.Name <> "Summary" Then
ws.Activate
End If
n = ActiveWorkbook.Worksheets.Count
For i = 1 To n
Cells(2, 1).Copy
Sheets("Summary").Activate
Sheets("Summary").Cells(i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next i
Next ws
Sheets("Dashboard").Visible = True
Sheets("Master").Visible = True
Sheets("Summary").Visible = True
End Sub
Please help out