Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through worksheets and get values from the current sheet

Status
Not open for further replies.

mxp346

MIS
Apr 27, 2002
50
0
0
US
I need a simple loop statement that will go through each worksheet in a workbook and then take certain values from that worksheet. Then it is going to run some other subs using the variables. Below is what I have. I believe I am doing something wrong with ActiveSheet part of it.


For Each sht In Sheets
If sht.name <> "Scripts" Then

Dim userid As String
Dim name As String
Dim defaultorg As String

userid = ActiveSheet.Range("C11").Value
name = ActiveSheet.Range("A11").Value
defaultorg = ActiveSheet.Range("E11").Value

CreateUser
CreateRoles

End If
Next


Thanks in advance for the help.
Matt
 
Hi,
Code:
Dim userid As String
Dim name As String
Dim defaultorg As String
    
For Each sht In Sheets
  With sht
    If .name <> "Scripts" Then
    
      userid = .Range("C11").Value
      name = .Range("A11").Value
      defaultorg = .Range("E11").Value
      
      CreateUser
      CreateRoles
    
    End If
   
  End with
Next


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top