Newbie2223
Technical User
Hi All
I have 2 macro that work well..the only problem is that I manually wait a 1minute to ensure that my worksheets have update befroe saving the Data to a .txt file.
Is there a way to make sure Refresh has stopped on the last sheet before continuing the macro
I have added 'Pls Help in my macro below.
Sub Update_Sheet()
'
' Update_Sheet Macro
' Macro recorded 05/11/08 by Matt
'
' Keyboard Shortcut: Ctrl+Shift+U
'
Sheets("PLS1").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS2").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS3").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS4").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS5").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS6").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PARAMETERS").Select
Range("A17").Select
'Pls Help
'Below is the part that I can't get to work ..I am trying to wait for the Last Sheet to
'stop refreshing before the macro continues to copy and save the Data to a simple .txt
'file
Do
Do While .Refreshing
Loop
Exit Do
'
'below is the saving part of the macro...works fine
Dim r, c As Integer
Close
Open "D:\Just_Text.txt" For Append As #1
For i = 3 To 7
With Worksheets(i).UsedRange
For r = 1 To .Rows.Count
For c = 1 To .Columns.Count - 1
Print #1, .Cells(r, c); "|";
Next c
Print #1, .Cells(r, .Columns.Count)
Next r
End With
Next i
Close #1
End Sub
I have 2 macro that work well..the only problem is that I manually wait a 1minute to ensure that my worksheets have update befroe saving the Data to a .txt file.
Is there a way to make sure Refresh has stopped on the last sheet before continuing the macro
I have added 'Pls Help in my macro below.
Sub Update_Sheet()
'
' Update_Sheet Macro
' Macro recorded 05/11/08 by Matt
'
' Keyboard Shortcut: Ctrl+Shift+U
'
Sheets("PLS1").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS2").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS3").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS4").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS5").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PLS6").Select
Cells(1, 1).Select
Selection.QueryTable.Refresh BackgroundQuery:=False
Sheets("PARAMETERS").Select
Range("A17").Select
'Pls Help
'Below is the part that I can't get to work ..I am trying to wait for the Last Sheet to
'stop refreshing before the macro continues to copy and save the Data to a simple .txt
'file
Do
Do While .Refreshing
Loop
Exit Do
'
'below is the saving part of the macro...works fine
Dim r, c As Integer
Close
Open "D:\Just_Text.txt" For Append As #1
For i = 3 To 7
With Worksheets(i).UsedRange
For r = 1 To .Rows.Count
For c = 1 To .Columns.Count - 1
Print #1, .Cells(r, c); "|";
Next c
Print #1, .Cells(r, .Columns.Count)
Next r
End With
Next i
Close #1
End Sub