Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A looping question


I saw the tutorial at
http://www.exceltip.com/st/Using_Loo...Excel/628.html
for looping but I need something a litle bit diffrent.

I want it to look in a file called subject.xls for the first name, go
to main.xls move 3 columns accross i.e. if I start at A it goes to D.

Get the value and paste it in subject.xls at the row of the same
person.

How can I do that?

Thank you for your help in advance.


--
thewebmaster
------------------------------------------------------------------------
thewebmaster's Profile: http://www.excelforum.com/member.php...o&userid=36601
View this thread: http://www.excelforum.com/showthread...hreadid=563428

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A looping question


This is what I have at the moment:


Code:
--------------------

Sub UserForm_Initialize()
Dim i As Integer
Dim SourceWB As Workbook
i = 1

Application.ScreenUpdating = False

Set SourceWB = Workbooks.Open("main.xls", _
False, True)

With Worksheets(1).Range("C:C")
Set c = .Find(Name, LookIn:=xlValues)
c.Activate
c.Value = "Banane"
If Not c Is Nothing Then
MsgBox ("no")

End If
End With
Name = SourceWB.Worksheets(1).Cells(i, 1).Value



SourceWB.Close False

Range("A5").Value = Name



Set SourceWB = Nothing

End Sub



--------------------


--
thewebmaster
------------------------------------------------------------------------
thewebmaster's Profile: http://www.excelforum.com/member.php...o&userid=36601
View this thread: http://www.excelforum.com/showthread...hreadid=563428

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A looping question


OK I managed to fix the loop but it doesn't want to copy the contents o
the cells.

Have a look at this please:


Sub UserForm_Initialize()
Dim i As Integer
Dim SourceWB As Workbook
i = 9

subjnumber = 1 ' change that to the subject number
Application.ScreenUpdating = False
Set SourceWB = Workbooks.Open("I:\Exam results\main.xls"
False, False) ' change that to where the main file is


For z = 2 To ActiveSheet.UsedRange.Rows.Count
thisname = Sheet1.Cells(z, 1)
MsgBox (thisname)

With SourceWB.Sheets(1)
For i = 9 To i + .UsedRange.Rows.Count
If .Cells(i, 3) = thisname Then
ActiveSheet.Cells(z, 9).Value = .Cells(i, 7
subjnumber)
ActiveSheet.Cells(z, 11).Value = .Cells(i, 64
subjnumber)
Exit For
End If
Next i
End With

Next z
SourceWB.Close False
Set SourceWB = Nothing
End Su

--
thewebmaste
-----------------------------------------------------------------------
thewebmaster's Profile: http://www.excelforum.com/member.php...fo&userid=3660
View this thread: http://www.excelforum.com/showthread.php?threadid=56342

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
Looping Question MWS Excel Programming 1 June 5th 06 08:17 PM
looping question Gary Keramidas[_2_] Excel Programming 1 May 31st 05 02:58 PM
Looping question Charles Excel Programming 2 April 20th 05 11:32 PM
Looping Question (I think?) MWS Excel Programming 2 October 27th 04 02:09 PM
Looping question Rune_Daub[_8_] Excel Programming 1 November 8th 03 04:06 PM


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