Linking using Macors

M

moflaher

Hello,

I am trying to create an error report based on multiple worksheets in
a workbook. I want to gather 7 or 8 cells from a worksheet and create
a new row in the error report with the information.

I have determine that using this function (='worksheet-name'!$C$7) i
can do it manually. the only macro that i have been able to come up
with hard codes the values in and i dont know how to have it loop
through all worksheets in my workbook.

Any help would be much appreciated

Mike
 
M

Mike

This may get you started
Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = ActiveWorkbook.Worksheets(i).Name
MsgBox "SheetName is:" & wsName & vbCrLf & _
"Value is" & Worksheets(wsName).Range("A1").Value
Next i
End Sub
 
M

moflaher

This may get you started
 Sub WorksheetLoop()
   Dim wsName As String
   Dim WS_Count As Integer
   Dim i As Integer
   WS_Count = _
   ActiveWorkbook.Worksheets.Count
   ' Begin the loop.
   For i = 1 To WS_Count
      wsName = ActiveWorkbook.Worksheets(i).Name
      MsgBox "SheetName is:" & wsName & vbCrLf & _
      "Value is" & Worksheets(wsName).Range("A1").Value
   Next i
End Sub









- Show quoted text -

This helped. thank you very much
 
R

Ron de Bruin

See also this page
http://www.rondebruin.nl/summary.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


This may get you started
Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = ActiveWorkbook.Worksheets(i).Name
MsgBox "SheetName is:" & wsName & vbCrLf & _
"Value is" & Worksheets(wsName).Range("A1").Value
Next i
End Sub









- Show quoted text -

This helped. thank you very much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top