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: 54
Default Help Reviewing My Loop

Hi- Could you help me determine why this program is not looping correctly? In
particular, the loop problem is that it does not open the next kregfile in
the for J loop.

Thank you!

Filo

---------------------------------------

Sub REENTERDETAIL2()


Dim deptnumber As String
Dim j As Integer
Dim Kregfile As String
Dim x As String


Application.ScreenUpdating = False
Application.DisplayAlerts = False

Rownumber = 21

For j = Rownumber To 22

ThisWorkbook.Activate
Sheets(1).Activate

Kregfile = Range("a" & j).Value

If Range("a" & j).Value = "" Then

Else

Workbooks.Open Filename:=Kregfile, UpdateLinks:=0
x = ActiveWorkbook.Name
MsgBox x

Sheets(2).Select
ActiveSheet.Unprotect "bud"

deptnumber = Left(Range("A1").Value, 5)
MsgBox deptnumber

For z = 1 To 65530
ThisWorkbook.Activate
Sheets("Detail").Select
If Cells(z, "A").Value = deptnumber Then

firstrow = z

For m = 65530 To 1 Step -1

If Range("A" & m).Value = deptnumber Then
lastrow = m



For f = firstrow To lastrow

MsgBox f


ThisWorkbook.Activate
Sheets("Detail").Select


t = Range("B" & f).Value
u = Range("F" & f).Value
o = Range("G" & f).Value

For y = 2 To 350

Workbooks(x).Activate
Sheets(2).Select
'" GRAND TOTAL - EXPENSES "

If Range("A" & y).Value = t Then

MsgBox t

s = y

y = 10000

Range("E" & s).Value = u
Range("F" & s).Value = o

Else

End If

Next y

Exit For

Next f

End If

Next m

End If

Next z

End If

Next j


End Sub
 
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
Reviewing Toolbar Default to Off Browning6 Excel Discussion (Misc queries) 1 June 29th 06 08:12 PM
Reviewing Tool Bar ONCPHY Excel Discussion (Misc queries) 0 March 13th 06 08:17 PM
Reviewing Problem ONCPHY Setting up and Configuration of Excel 0 March 7th 06 04:52 PM
Reviewing Toolbar DJ Excel Discussion (Misc queries) 1 May 26th 05 09:11 PM
reviewing toolbar always there... JEV Excel Discussion (Misc queries) 1 February 23rd 05 10:14 PM


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

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

About Us

"It's about Microsoft Excel"