View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Help with VBA code

HS,
It is normally a good starting point to record your actions in a macro
(ToolsMacrorecord New Macro) to give you a direction.

As a start, look into the For Each .. In. .. loop
And you would need to test each WS to see if it is of interest to you.

In your case, something like:
Dim WS as Worksheet
For Each WS In Thisworkbook
If WS.Name<Activesheet.Name Then
With WS
.Range("A1").Value=1 'Whatever the value and cell
.Range("A2").Value=2 '...
'Total the values as required
End With
End If
Next

NickHK


wrote in message
oups.com...
Hi

I am a true beginner at Excel. I want to be able to iterate through
almost all worksheets, add some values as I go along, and display the
total into cells of another sheet within the same workbook.
This is the scenario. I have a workbook with x worksheets. At the click
of a button I want to be able to iterate through all worksheets except
the worksheet where the button resides.
As the program iterates through all the worksheets in the workbook, it
allots the values of a few common cells throughout each worksheet. Once
it has gone through all the worksheets (except the last one), it should
render the total for each common cell unto cells specific to each value
total.
I tried winging this on my own, by I am not good at this VBA language.
Can someone please help me with some code or point me in the direction
where I can find a good VBA reference?
I would really appreciate it.

Thanks
HS