Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 105
Default Simple Macro to "Lookup - Repeat"

Hi everyone,

I have two sheets in my workbook containing addresses.

i.e.
- Sheet("A") containing addresses from cell E2 downwards.
- Sheet("B") capturing addresses from Sheet("A") from cell A5


How do I capture original address(unique address) from Sheet("A") and
repeat it eight times in Sheet("B") from cell A5 downards and move on
to the next unique address on Sheet("A").

e.g.
If Range("E2:E5") in Sheet("A") are as below:

E2: Brisbane (59)
E3: Brisbane (79)
E4: Perth (20)
E5: Sydney (30)


I want Sheet("B") from A5 to be as below:

A5: Brisbane (59)
A6: Brisbane (59)
A7: Brisbane (59)
A8: Brisbane (59)
A9: Brisbane (59)
A10: Brisbane (59)
A11: Brisbane (59)
A12: Brisbane (59)
A13: Brisbane (79)
A14: Brisbane (79)
A15: Brisbane (79)
A16: Brisbane (79)
A17: Brisbane (79)
A18: Brisbane (79)
A19: Brisbane (79)
A20: Brisbane (79)

and so on...

Thank you for your help in advance.


Regards,


James

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Simple Macro to "Lookup - Repeat"

try:

Sub cus()
Dim counter As Integer
Dim i As Integer
Dim cell As Range

For Each cell In Sheets("A").Columns(5).Cells
If Len(cell) 0 Then
For i = 1 To 8
counter = counter + 1
Sheets("B").Cells(4 + counter, 1) = cell
Next i
Else
Exit Sub
End If
Next cell

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default Simple Macro to "Lookup - Repeat"

replace
For Each cell In Sheets("A").Columns(5).Cells


with

For Each cell In Sheets("A").Range("E2:E10000").Cells
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple Macro to "Lookup - Repeat"


Perhaps something like this:

Sub copycells()
Dim Rng As Range, Rng1 As Long
Dim MyCell As Range, oCell As Range
Dim i As Long
Set Rng = Sheets("Sheet1").Range("E2:E" & Range("E" &
Rows.Count).End(xlUp))
For Each MyCell In Rng
Rng1 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(0,
1).Row
MyCell.Copy Destination:=Sheets("Sheet2").Range(Cells(Rng1, 1),
Cells(Rng1 + 8, 1))
Next
End Sub


--
The Code Cage Team

Regards,
The Code Cage Team
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=32425

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
how does this formula work: =LOOKUP(2,1/((COUNTIF(D6:D41,""&D6:D41)=0)*(D6:D41<"")),D6:D41) Dave F[_2_] Excel Discussion (Misc queries) 7 February 1st 09 03:42 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Replacing "IF" or "LOOKUP" formula's with VBA Function? dhunter43 Excel Programming 0 August 10th 07 06:52 PM
Replacing "IF" or "Lookup" formulas with VBA function dhunter43 Excel Programming 6 August 10th 07 06:22 PM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM


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