LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default For Each Sheet in Workbook

I wasnt really trying to establish a 3D range, I was trying to get VBA
to return the value on the same range on each WS.
The nested For Each Sh In ThisWorkbook.Worksheets did just that.

Sub GenSwp()
Dim DifInDys, SwpGn, Ct As Integer
Dim UFdate, DtRg As Date
Dim Sh, wsData As Worksheet
Set wsData = Worksheets("Data")
UFdate = wsData.Range("E26").Value
SwpGn = wsData.Range("E24").Value
Select Case SwpGn
Case Is = 1
For Each Sh In ThisWorkbook.Worksheets
If Sh.Name Like "EDL *" Then
DtRg = Sh.Range("O1").Value
If DtRg = UFdate Then
DifInDys = DtRg - UFdate
If Abs(DifInDys) Mod 2 = 1 Then
Select Case True
Case Is = wsData.Range("E20")
Sh.Range("H23").Value = ""
Sh.Range("J23") = 24
Case Is = wsData.Range("E22")
Sh.Range("J23").Value = ""
Sh.Range("H23") = 24
End Select
Else
Select Case True
Case Is = wsData.Range("E20")
Sh.Range("J23").Value = ""
Sh.Range("H23") = 24
Case Is = wsData.Range("E22")
Sh.Range("H23").Value = ""
Sh.Range("J23") = 24
End Select
End If
End If
End If
Next Sh
Case Is = 2

This is the code Im working on.WS(Data) is a hidden Sh. The values
SwpGn,and UFdate are edited thru a UserForm, SwpGn can be an integer
from 1-7. The Select Case True test value is entered from the same
UserForm by two Checkboxes.This code enters the integer 24 alternatly
between two ranges depending on the date in DtRg.
It works when SwpGn.value=1. But if SwpGn.value was to equal to another
number,, say, 2, then I need the 24 to be entered for two days in a row
in one column, then two days in a row in the other column. SwpGn=3 then
24 needs to be in the same column for three days straight, then the
other column for the next 3 days.

Im a little stuck right now, What I need to do for Case Is = 2, is for
VBA to run the code then go to Next Sh (next day), and do the same thing
for that sheet. Then go to the next two Sh's and place the value 24 in
the alternate column. So on...
Then Ill be at Case Is = 3 !! all the way to Case Is = 7...
I have considered adding a For Ct= 0 To * depending on SwpGn.value, If
DtRg = UFdate+Ct Then
But say SwpGn.value=2
For Ct= 0 To 1
If DtRg = UFdate+Ct Then
This would only run through the WS that matched UFdate and the next day.
So,,, thats what Im working on.
Aint ya glad ya asked!!?
Lloyd

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy sheet cells into differnt workbook/sheet, How? IVLUTA Excel Discussion (Misc queries) 2 June 2nd 09 11:16 PM
Link individual sheet to one sheet in another workbook dfield Excel Discussion (Misc queries) 1 March 12th 06 02:26 AM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy Excel Discussion (Misc queries) 1 June 10th 05 12:17 AM
I would like to move from sheet to sheet in a workbook using keybo k-cess New Users to Excel 1 April 12th 05 03:23 AM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"