Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Info From Another Sheet


Hi All
I need to get cell entries from another sheet and I don't know how man
rows will be involved. I have the following code that gives me th
right info but, as you can see, only if there are up to 3 row
involved. Can anyone sugest how I could use an array to get my inf
regardless of the number of rows involved?
Thanks in advance
Liz

If SheetExists("Address") Then
Range("C2").Select

If Range("Address!G2") 0 Then
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[4]&"
""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C3").Select
Else
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[5]&"
""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C3").Select
End If

If Range("Address!G3") 0 Then
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[4]&"
""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C4").Select
Else
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[5]&"
""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C4").Select
End If

If Range("Address!G4") 0 Then
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[4]&"
""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C5").Select
Else
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[5]&"
""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C5").Select
End If

Else
Range("C2").Select
ActiveCell.FormulaR1C1 = "None"
End I

--
Liz
-----------------------------------------------------------------------
LizS's Profile: http://www.excelforum.com/member.php...fo&userid=2899
View this thread: http://www.excelforum.com/showthread.php?threadid=48719

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Get Info From Another Sheet

sFormula = "&""""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7]"
If SheetExists("Address") Then
For i = 2 To Cells(Rows.Count, "G").End(xlUp).Row
If Worksheets("Address").Range("G" & i) 0 Then
Cells(i, "C").FormulaR1C1 = _
"=Address!RC[3]&""""&Address!RC[4]" & sFormula
Else
Cells(i, "C").FormulaR1C1 = _
"=Address!RC[3]" & sFormula
End If
Next i
Else
Range("C2").Value = "None"
End If


--

HTH

RP
(remove nothere from the email address if mailing direct)


"LizS" wrote in message
...

Hi All
I need to get cell entries from another sheet and I don't know how many
rows will be involved. I have the following code that gives me the
right info but, as you can see, only if there are up to 3 rows
involved. Can anyone sugest how I could use an array to get my info
regardless of the number of rows involved?
Thanks in advance
Liz

If SheetExists("Address") Then
Range("C2").Select

If Range("Address!G2") 0 Then
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[4]&""
""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C3").Select
Else
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[5]&""
""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C3").Select
End If

If Range("Address!G3") 0 Then
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[4]&""
""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C4").Select
Else
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[5]&""
""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C4").Select
End If

If Range("Address!G4") 0 Then
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[4]&""
""&Address!RC[5]&"" ""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C5").Select
Else
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(Address!RC[3]&"" ""&Address!RC[5]&""
""&Address!RC[6]&"" ""&Address!RC[7])"
Range("C5").Select
End If

Else
Range("C2").Select
ActiveCell.FormulaR1C1 = "None"
End If


--
LizS
------------------------------------------------------------------------
LizS's Profile:

http://www.excelforum.com/member.php...o&userid=28991
View this thread: http://www.excelforum.com/showthread...hreadid=487198



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Info From Another Sheet


Thanks for the reply Bob
I've tried your code but it goes from

For i = 2 To Cells(Rows.Count, "G").End(xlUp).Row

to

End If

Count contains 65536 and i is empty

Regards
Liz


--
LizS
------------------------------------------------------------------------
LizS's Profile: http://www.excelforum.com/member.php...o&userid=28991
View this thread: http://www.excelforum.com/showthread...hreadid=487198

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Get Info From Another Sheet

I know that Rows.Count is 65536, but what do you mean by i is empty? It
starts as empty, but as soon as you enter the For loop, it gets initialised.

I tried it on some test data, and it worked fine. What exactly do you
experience?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"LizS" wrote in message
...

Thanks for the reply Bob
I've tried your code but it goes from

For i = 2 To Cells(Rows.Count, "G").End(xlUp).Row

to

End If

Count contains 65536 and i is empty

Regards
Liz


--
LizS
------------------------------------------------------------------------
LizS's Profile:

http://www.excelforum.com/member.php...o&userid=28991
View this thread: http://www.excelforum.com/showthread...hreadid=487198



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Info From Another Sheet


Thanks Bob and apologies for my mistake - I did update my thread but
obviously after you'd looked at it. i is 2 (not empty as I previously
said.

I get no result in my cell and when I step through the code it goes
straight from the For statement to the end if.

I have attached a sample of the Address sheet with another sheet
showing my entire macro incase something else I am doing is affecting
it.

Thanks for your time and expertise on this.
Regards
Liz


+-------------------------------------------------------------------+
|Filename: AddressExample.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4058 |
+-------------------------------------------------------------------+

--
LizS
------------------------------------------------------------------------
LizS's Profile: http://www.excelforum.com/member.php...o&userid=28991
View this thread: http://www.excelforum.com/showthread...hreadid=487198



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Info From Another Sheet


Bob
I have sussed out my problem - When I do the For statement I'm on a
sheet that has nothing in G. When I change to Address and run it, it's
fine. I now have the following problem

sFormula = "&""""&Address!RC[5]&"" ""&Address!RC[6]&""
""&Address!RC[7]"
If SheetExists("Address") Then
Worksheets("Address").Activate
For i = 2 To Cells(Rows.Count, "G").End(xlUp).Row
Worksheets("Sheet14").Activate
If Worksheets("Address").Range("G" & i) 0 Then
Cells(i, "C").FormulaR1C1 = _
"=Address!RC[3]&""""&Address!RC[4]" & sFormula
Else
Cells(i, "C").FormulaR1C1 = _
"=Address!RC[3]" & sFormula
End If
Next i
Else
Range("C2").Value = "None"
End If

How do I store the sheet name in a variable? In my example the new
sheet is Sheet14 but that won't always be the case.

Thanks again for your time
Regards
Liz


--
LizS
------------------------------------------------------------------------
LizS's Profile: http://www.excelforum.com/member.php...o&userid=28991
View this thread: http://www.excelforum.com/showthread...hreadid=487198

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
Annual Wages Sheet to pick up info from Time Sheet stallence Excel Worksheet Functions 2 May 5th 08 11:02 PM
Finding Info from sheet 1 and removing only those rows from sheet Johnny B[_2_] Excel Discussion (Misc queries) 1 March 28th 07 02:29 PM
TAKING INFO FROM ONE SHEET AND PRODUCING A LIST IN ANOTHER SHEET Bob Excel Discussion (Misc queries) 0 December 20th 06 07:45 PM
How do I compare info in on sheet to info in another? Fanney Excel Discussion (Misc queries) 7 February 25th 06 02:16 AM
transfering info from one sheet to another based on info being transferred CClarke Excel Programming 0 January 14th 04 08:04 PM


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