Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to write a macro 30 Nov?

Does anyone have any suggestions on how I can insert the Counter into the web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding section

If the counter is 1, then paste into Columns("A:A").Select under Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under Summary
worksheet.

....

If the counter is 10, then paste into Columns("J:J").Select under Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to write a macro 30 Nov?

Eric,

I'm not entirely clear what your trying to do but this does what I think
your asking. Note a couple of things. I 've stopped all the sheet selection
it isn't necessary and I don't paste into columns "A:A" I user the variable
'counter to select the column to paste in to.

Sheets("Sheet2").Columns(counter).PasteSpecial


Sub sonic()
For counter = 1 To 10
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:=Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Columns("F:F").Copy
Sheets("Sheet2").Columns(counter).PasteSpecial
Next counter
End Sub

"Eric" wrote:

Does anyone have any suggestions on how I can insert the Counter into the web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding section

If the counter is 1, then paste into Columns("A:A").Select under Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to write a macro 30 Nov?

Thank you very much for suggestions

Could you please give me any suggestions on how to edit the link?
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"
I would like to retrieve the value from counter and insert into 1
If counter is 1, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"

If counter is 2, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=2"

....

If counter is 10, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=10"

Do you have any suggestions
Thank everyone very much for any suggestions
Eric



"Mike H" wrote:

Eric,

I'm not entirely clear what your trying to do but this does what I think
your asking. Note a couple of things. I 've stopped all the sheet selection
it isn't necessary and I don't paste into columns "A:A" I user the variable
'counter to select the column to paste in to.

Sheets("Sheet2").Columns(counter).PasteSpecial


Sub sonic()
For counter = 1 To 10
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:=Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Columns("F:F").Copy
Sheets("Sheet2").Columns(counter).PasteSpecial
Next counter
End Sub

"Eric" wrote:

Does anyone have any suggestions on how I can insert the Counter into the web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding section

If the counter is 1, then paste into Columns("A:A").Select under Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to write a macro 30 Nov?

Assuming the link is stored in a variable named Link and the counter is
stored in a variable named Counter AND assuming the page value is ALWAYS
located at the end of the link's text (that is very important), then this
will change the page to the value of the counter...

Link = Left(Link, InStrRev(Link, "=")) & Counter

--
Rick (MVP - Excel)


"Eric" wrote in message
...
Thank you very much for suggestions

Could you please give me any suggestions on how to edit the link?
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"
I would like to retrieve the value from counter and insert into 1
If counter is 1, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"

If counter is 2, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=2"

...

If counter is 10, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=10"

Do you have any suggestions
Thank everyone very much for any suggestions
Eric



"Mike H" wrote:

Eric,

I'm not entirely clear what your trying to do but this does what I think
your asking. Note a couple of things. I 've stopped all the sheet
selection
it isn't necessary and I don't paste into columns "A:A" I user the
variable
'counter to select the column to paste in to.

Sheets("Sheet2").Columns(counter).PasteSpecial


Sub sonic()
For counter = 1 To 10
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:=Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Columns("F:F").Copy
Sheets("Sheet2").Columns(counter).PasteSpecial
Next counter
End Sub

"Eric" wrote:

Does anyone have any suggestions on how I can insert the Counter into
the web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding
section

If the counter is 1, then paste into Columns("A:A").Select under
Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under
Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under
Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to write a macro 30 Nov?

Thank everyone very much for suggestions

Do you mean like following codes?
There is some error on following coding
Does anyone have any suggestions?
Thank everyone very much for any suggestions
Eric

Sub sonic()
Link = "URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"

For counter = 1 To 10
Link = Left(Link, InStrRev(Link, "=")) & Counter
With ActiveSheet.QueryTables.Add(Connection:= _
Link, Destination:=Range("A1"))
.Name = "Link"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Columns("F:F").Copy
Sheets("Sheet2").Columns(counter).PasteSpecial
Next counter
End Sub


"Rick Rothstein" wrote:

Assuming the link is stored in a variable named Link and the counter is
stored in a variable named Counter AND assuming the page value is ALWAYS
located at the end of the link's text (that is very important), then this
will change the page to the value of the counter...

Link = Left(Link, InStrRev(Link, "=")) & Counter

--
Rick (MVP - Excel)


"Eric" wrote in message
...
Thank you very much for suggestions

Could you please give me any suggestions on how to edit the link?
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"
I would like to retrieve the value from counter and insert into 1
If counter is 1, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1"

If counter is 2, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=2"

...

If counter is 10, then
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=10"

Do you have any suggestions
Thank everyone very much for any suggestions
Eric



"Mike H" wrote:

Eric,

I'm not entirely clear what your trying to do but this does what I think
your asking. Note a couple of things. I 've stopped all the sheet
selection
it isn't necessary and I don't paste into columns "A:A" I user the
variable
'counter to select the column to paste in to.

Sheets("Sheet2").Columns(counter).PasteSpecial


Sub sonic()
For counter = 1 To 10
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:=Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Columns("F:F").Copy
Sheets("Sheet2").Columns(counter).PasteSpecial
Next counter
End Sub

"Eric" wrote:

Does anyone have any suggestions on how I can insert the Counter into
the web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding
section

If the counter is 1, then paste into Columns("A:A").Select under
Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under
Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under
Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default How to write a macro 30 Nov?

Establish your web query and then refresh INSTEAD of adding again by using
this.

Sub RefreshAndCopy()
Sheets("sheet1").QueryTables(1).Refresh

With Sheets("sheet2")
lc = .Cells.Find(What:="*", _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column + 1
'MsgBox lc
Sheets("sheet1").Columns("f").Copy .Columns(lc)
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
Does anyone have any suggestions on how I can insert the Counter into the
web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding section

If the counter is 1, then paste into Columns("A:A").Select under Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default How to write a macro 30 Nov?

Thank everyone very much for suggestions

Could you please give me the example with loop and web link location?
I get no idea where to place my web link, and loop
Thank everyone very much for any suggestions
Eric

"Don Guillett" wrote:

Establish your web query and then refresh INSTEAD of adding again by using
this.

Sub RefreshAndCopy()
Sheets("sheet1").QueryTables(1).Refresh

With Sheets("sheet2")
lc = .Cells.Find(What:="*", _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column + 1
'MsgBox lc
Sheets("sheet1").Columns("f").Copy .Columns(lc)
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
Does anyone have any suggestions on how I can insert the Counter into the
web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding section

If the counter is 1, then paste into Columns("A:A").Select under Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default How to write a macro 30 Nov?

After you establish the FIRST one in sheet 1, then use this to loop thru the
10 to refresh and copy col F to the next available column in sheet 2. Hide
the first 22 rows on sheet2. Contact me privately if desired.

Sub queryloop()
For i = 2 To 10 'number desired
With Sheets("sheet1").QueryTables(1)
.Connection = "URL;http://www2.uwants.com/forumdisplay.php?fid=845&page="
& i
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

With Sheets("sheet2")
cc = .Columns.Count
'MsgBox cc
lc = .Cells.Find(What:="*", _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column + 1
'MsgBox lc
Sheets("sheet1").Columns("f").Copy .Columns(lc)
End With
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
Thank everyone very much for suggestions

Could you please give me the example with loop and web link location?
I get no idea where to place my web link, and loop
Thank everyone very much for any suggestions
Eric

"Don Guillett" wrote:

Establish your web query and then refresh INSTEAD of adding again by
using
this.

Sub RefreshAndCopy()
Sheets("sheet1").QueryTables(1).Refresh

With Sheets("sheet2")
lc = .Cells.Find(What:="*", _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column + 1
'MsgBox lc
Sheets("sheet1").Columns("f").Copy .Columns(lc)
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
Does anyone have any suggestions on how I can insert the Counter into
the
web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding
section

If the counter is 1, then paste into Columns("A:A").Select under
Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under
Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under
Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default How to write a macro 30 Nov?


Actually, could be a little simpler

Sub queryloop()
For i = 2 To 4
With Sheets("sheet1").QueryTables(1)
.Connection = "URL;http://www2.uwants.com/forumdisplay.php?fid=845&page=" &
i
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

Sheets("sheet1").Columns("f").Copy Sheets("sheet2").Columns(i)

Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
After you establish the FIRST one in sheet 1, then use this to loop thru
the 10 to refresh and copy col F to the next available column in sheet 2.
Hide the first 22 rows on sheet2. Contact me privately if desired.

Sub queryloop()
For i = 2 To 10 'number desired
With Sheets("sheet1").QueryTables(1)
.Connection =
"URL;http://www2.uwants.com/forumdisplay.php?fid=845&page=" & i
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

With Sheets("sheet2")
cc = .Columns.Count
'MsgBox cc
lc = .Cells.Find(What:="*", _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column + 1
'MsgBox lc
Sheets("sheet1").Columns("f").Copy .Columns(lc)
End With
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
Thank everyone very much for suggestions

Could you please give me the example with loop and web link location?
I get no idea where to place my web link, and loop
Thank everyone very much for any suggestions
Eric

"Don Guillett" wrote:

Establish your web query and then refresh INSTEAD of adding again by
using
this.

Sub RefreshAndCopy()
Sheets("sheet1").QueryTables(1).Refresh

With Sheets("sheet2")
lc = .Cells.Find(What:="*", _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column + 1
'MsgBox lc
Sheets("sheet1").Columns("f").Copy .Columns(lc)
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Eric" wrote in message
...
Does anyone have any suggestions on how I can insert the Counter into
the
web
link? and change the column location for pasting selection?

Following code is generated by recording Macro, please see Coding
section

If the counter is 1, then paste into Columns("A:A").Select under
Summary
worksheet.

If the counter is 2, then paste into Columns("B:B").Select under
Summary
worksheet.

...

If the counter is 10, then paste into Columns("J:J").Select under
Summary
worksheet.

Does anyone have any suggestions?
Thanks in advance forany suggestions
Eric


===============
Coding
===============

For Counter = 1 to 10
'Your code
Next Counter


With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.uwants.com/forumdisplay.php?fid=845&page=1",
Destination:= _
Range("A1"))
.Name = "forumdisplay.php?fid=845&page=1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.LargeScroll ToRight:=2
Columns("F:F").Select
Selection.Copy
Sheets("Sheet2").Select
Columns("A:A").Select
ActiveSheet.Paste
End Sub





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
Trying to write a macro john mcmichael Excel Programming 4 November 8th 06 04:21 PM
Help write Macro nc Excel Discussion (Misc queries) 5 November 17th 05 03:19 PM
How to write a macro?? Keeter Excel Discussion (Misc queries) 1 July 19th 05 08:34 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Need help to write macro please Bob[_57_] Excel Programming 6 May 28th 04 01:21 AM


All times are GMT +1. The time now is 03:55 PM.

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

About Us

"It's about Microsoft Excel"