Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Loop in a Macro

Hi all,

Here is a small macro to pull data into from web.

Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://incometaxindiaefiling.gov.in/...n/tanpage.jsp?
tan=0", _
Destination:=Range("A1"))
.Name = "tanpage.jsp?tan=1"
.FieldNames = True
.PreserveFormatting = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=True
End With
End Sub

It is working perfectly for downloading data. My Problems is there are
n number of such pages, which need to be downloaded. How can I use
loops or something else so that parameter 0 in first line is increased
automatically by one till in reaches n and Destination range by 20
cells (i.e., A21, A41 and so on). New destination range would be here
equal to (n*20)+1

Regards
CA Kanwaljit Singh Dhunna
India
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop in a Macro


from
tan=0",
to
tan=" & loopcount,

" wrote:

Hi all,

Here is a small macro to pull data into from web.

Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://incometaxindiaefiling.gov.in/...n/tanpage.jsp?
tan=0", _
Destination:=Range("A1"))
.Name = "tanpage.jsp?tan=1"
.FieldNames = True
.PreserveFormatting = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=True
End With
End Sub

It is working perfectly for downloading data. My Problems is there are
n number of such pages, which need to be downloaded. How can I use
loops or something else so that parameter 0 in first line is increased
automatically by one till in reaches n and Destination range by 20
cells (i.e., A21, A41 and so on). New destination range would be here
equal to (n*20)+1

Regards
CA Kanwaljit Singh Dhunna
India

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop in a Macro


from
tan=0",
to
tan=" & loopcount,

" wrote:

Hi all,

Here is a small macro to pull data into from web.

Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://incometaxindiaefiling.gov.in/...n/tanpage.jsp?
tan=0", _
Destination:=Range("A1"))
.Name = "tanpage.jsp?tan=1"
.FieldNames = True
.PreserveFormatting = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=True
End With
End Sub

It is working perfectly for downloading data. My Problems is there are
n number of such pages, which need to be downloaded. How can I use
loops or something else so that parameter 0 in first line is increased
automatically by one till in reaches n and Destination range by 20
cells (i.e., A21, A41 and so on). New destination range would be here
equal to (n*20)+1

Regards
CA Kanwaljit Singh Dhunna
India

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Loop in a Macro


from
tan=0",
to
tan=" & loopcount,

" wrote:

Hi all,

Here is a small macro to pull data into from web.

Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://incometaxindiaefiling.gov.in/...n/tanpage.jsp?
tan=0", _
Destination:=Range("A1"))
.Name = "tanpage.jsp?tan=1"
.FieldNames = True
.PreserveFormatting = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=True
End With
End Sub

It is working perfectly for downloading data. My Problems is there are
n number of such pages, which need to be downloaded. How can I use
loops or something else so that parameter 0 in first line is increased
automatically by one till in reaches n and Destination range by 20
cells (i.e., A21, A41 and so on). New destination range would be here
equal to (n*20)+1

Regards
CA Kanwaljit Singh Dhunna
India

Reply
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
Do until loop with use of another macro in loop The Excelerator Excel Programming 9 February 28th 07 02:28 AM
macro loop DM Excel Discussion (Misc queries) 1 January 3rd 06 10:46 PM
VBA Macro Loop Neutron1871 Excel Programming 1 November 4th 04 09:22 AM
I Need Help with my loop macro Pete Excel Programming 1 January 16th 04 04:02 PM


All times are GMT +1. The time now is 03:18 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"