LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default How would I add a loop for this?

I had worked on this earlier and had to put it aside; now I have to
come back to it...
The code below is what I am doing currently. The "Open Filename...c1"
is only one of many workbooks that would be opened. I name these
c1,c2,c3 etc...Example this time I may only have 3 "C's". Next time it
could be 7 "C's".
What I want to do is this, once the code below runs and is completed,
then go and find the next "C*.htm in the folder and do this code again,
but place the data in the next adjacent column, in this case column E.

Last, the sumproduct works correctly and it runs thru about 400 rows
filling in data. It takes about 45 seconds at this time. Is there a VBA
code that would do this faster?


Thanks,

Hans

Sub getdata()
Dim ColumnTest As Workbook

Workbooks.Open Filename:=ThisWorkbook.Path & "\c1.htm"
Windows("C1.htm").Activate

Range("A9").Select
Selection.Copy
Windows("Column Test.xls").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
With Selection.Font
.Name = "Tahoma"
.Size = 8
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
End With
End With

Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
With .Range("D6:D" & LastRow)
.Formula =
"=SUMPRODUCT((c1.htm!$A$1:$A$65000=$C6)*(c1.htm!$E $1:$E$65000=""yes""))-SUMPRODUCT((c1.htm!$A$1:$A$65000=$C6)*(c1.htm!$D$1 :$D$65000=""Would
you like to add any comments?"")*(c1.htm!$E$1:$E$65000=""yes""))"
.Value = .Value
End With

End With


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
Loop time seems dependent on unrelated workbook - Why? Richard Excel Worksheet Functions 2 March 30th 06 11:59 PM
Loop gone crazy Dave Peterson Excel Discussion (Misc queries) 4 December 16th 05 03:38 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
VB for excel, how do I loop through code steve hobden via OfficeKB.com Excel Discussion (Misc queries) 2 June 9th 05 01:59 PM
loop trough e-mail address list to send task lists with outlook Paul. Excel Discussion (Misc queries) 2 April 14th 05 11:48 AM


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