LOOPING THROUGH WORKSHEETS!

  • Thread starter Thread starter jay dean
  • Start date Start date
J

jay dean

Hello -

In each worksheet of the workbook Test.xls, ONE cell is manually
selected.
I need a macro that will loop through all the sheets in the workbook
except the worksheet labeled "Display", and concatenate the value of the
selected cells in the sheets, then place the concatenated string in
Range("D12") of the workshsheet labeled "Display".

Any help would be appreciated.
Thanks
Jay
 
Hi Jay

Try this:

Sub BBB()
Dim MyString As String
For Each sh In ActiveWorkbook.Sheets
If sh.Name <> "Display" Then
MyString = MyString & " " & sh.ActiveCell.Value
End If
Next
Sheets("Display").Range("D12") = MyString
End Sub

Best regards,
Per
 
Sub MyMacro()

Application.ScreenUpdating = False
Dim MyString As String
For Each sh In ActiveWorkbook.Sheets
sh.Activate
If sh.Name <> "Display" Then
MyString = MyString & " " & ActiveCell.Value
End If
Next
Sheets("Display").Range("D12") = MyString
Application.ScreenUpdating = True

End Sub

If this post helps click Yes
 
Hello Per -

I tried it but it gave me the error:
"Object doesn't support this prpoerty or method", then highlighted the
liene "MyString = MyString & " " & sh.ActiveCell.Value" when I clicked
debug.

I think it is not accepting the "ActiveCell" property for the loop?


Thanks
Jay
 
'Enhanced..

Sub MyMacro()

Application.ScreenUpdating = False
Dim MyString As String
For Each sh In ActiveWorkbook.Sheets
sh.Activate
If sh.Name <> "Display" Then
MyString = MyString & " " & ActiveCell.Value
End If
Next
Sheets("Display").Activate
Application.ScreenUpdating = True
Sheets("Display").Range("D12") = MyString

End Sub


If this post helps click Yes
 
Try

Sub Stance()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Display" Then
ws.Select
tempstring = tempstring & ActiveCell.Value
End If
Next
Sheets("Display").Range("D12") = tempstring
End Sub


Mike
 

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

Back
Top