-
Open 2 worksheet at the same time
[VBA]lr_Total = FormatPercent((lr1 / (lr1 + lr2)), 4)
Worksheets("LW").Activate
For Each rngcell In Range("A3:G3" & Range("A" & Rows.Count).End(xlUp).Row)
Ch1 = DateDiff("d", Range("A" & rngcell.Row).Value, LValue)
Ch2 = DateDiff("d", LValue, Range("B" & rngcell.Row).Value)
If Ch1 >= 0 And Ch2 >= 0 Then
Worksheet(""cal").Range("R1") = lr_Total
End If
Next[/VBA]
My program get error. How to run 2 worksheet at the same time in the loop?
Or got better suggestion?
-
Please be more specific on the error. F8 will step through the code. Obviously, unequal quotes cause a syntax error.
e.g.
[vba]Worksheet(""cal").Range("R1") = lr_Total [/vba]
Select and Activate are seldom needed. Simply prefix what you need with the worksheet object name.
e.g.
[vba]Dim cal as worksheet, lw as worksheet
set cal = Worksheets("Cal")
Set lw = Worksheets("LW")
cal.Range("Ra").value = lr_Total[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules