LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KK KK is offline
external usenet poster
 
Posts: 61
Default Looping(Rookies)

Private Sub cbFile_Click()

'returns your full file name.
File_Name = Application.GetOpenFilename("MS Excel Files (*.xls),*.xls")

'hence no len, no name...
If Len(File_Name) = 0 Then Exit Sub

tbFile.Value = File_Name

End Sub

Private Sub cbStart_Click()

Workbooks.Open (tbFile)

Dim x As Integer
Dim y As Integer
Dim z As String

y = 4
For x = 2 To 930

Sheets("Task_Table1").Select
Application.Goto Reference:="R" & x & "C13"

ActiveCell.FormulaR1C1 =
"=IF((LEFT(RC[-8],LEN(RC[-8])-4)+1)11,(IF(RC[-6]<""Yes"",(IF(RC[-3]<1,""YES"",""No"")),""No"")),""No"")"
z = ActiveCell.Value


If (z < "No") Then

Workbooks("Project_Analyzer_v2").Activate
Set wb = Workbooks.Open(tbFile, True, True)


Application.ScreenUpdating = False ' turn off the screen updating

' open the source workbook, read only
With ThisWorkbook.Worksheets("Duration Test")

.Range("B1").Formula = "File : " & tbFile.Value
.Range("B2").Formula = "Test Completed : " & FormatDateTime(Now())

.Range("A3").Formula = "ID"
.Range("B3").Formula = "Task"
.Range("C3").Formula = "Duration"
.Range("D3").Formula = "Start Date"
.Range("E3").Formula = "Finish Date"
' read data from the source workbook
.Range("A" & y).Formula = wb.Worksheets("Task_Table1").Range("A" &
x).Formula
.Range("B" & y).Formula = wb.Worksheets("Task_Table1").Range("B" &
x).Formula
.Range("C" & y).Formula = wb.Worksheets("Task_Table1").Range("E" &
x).Formula
.Range("D" & y).Formula = wb.Worksheets("Task_Table1").Range("C" &
x).Formula
.Range("E" & y).Formula = wb.Worksheets("Task_Table1").Range("D" &
x).Formula

End With

Set wb = Nothing
Application.ScreenUpdating = True ' turn on the screen updating
y = y + 1
ActiveSheet.Cells.Select
ActiveSheet.UsedRange.Columns.AutoFit

Set wb = Nothing ' free memory
Else
End If
Next x






End Sub



Every time when i run this code , if the statement is true , will pop out
one MSG box to reopen the file......any problem in looping?

 
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
If statement(rookies) KK Excel Programming 3 July 21st 09 11:03 AM
Looping LaDdIe Excel Programming 3 December 7th 08 06:19 PM
Looping...but why? cherrynich Excel Programming 2 May 12th 06 04:57 PM
Help with Looping I think Mike Excel Programming 2 April 25th 06 04:23 PM
Looping [email protected] Excel Programming 0 October 31st 03 07:47 PM


All times are GMT +1. The time now is 10:03 AM.

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"