Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding all the values and storing them


I am novice in VBA.

Can someone please help me do the following.

I have 2 sheets

Sheet1 - contains all the information
Sheet2 - where I want the code to put some of the information

I would like the code to start in Sheet1 - A2:A100. If the cell = 61538
then
put the corresponding B column value {offset (0,1)} in Sheet2 A2.

Go through all 100 rows and do the same....

So if it finds the first occurence of 61538 in Sheet1 - A7 it will put
the offset(o,1).value in Sheet2 - A2.

Then if the next occurence is Sheet1 - A55 it will put the
offset(0,1).value in Sheet2 - A3 *** the next open cell***

Thank you for any help on this matter.....

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=544439

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding all the values and storing them


try


Sub a()
Dim rng1 As Range
Dim rng2 As Range

Set rng1 = Worksheets("Sheet1").Range("A2")
Set rng1 = Worksheets("Sheet2").Range("A2")

Do
If rng1 = 61538 Then
rng2 = rng1.Offset(, 1)
Set rng2 = rng2.Offset(1)
End If

Set rng1 = rng1.Offset(1)
Loop Until rng1.Row = 100
MsgBox "done"
End Sub


cheer

--
tony
-----------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=54443

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding all the values and storing them


the code isn't putting anything on Sheet

--
jhahe
-----------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...fo&userid=2359
View this thread: http://www.excelforum.com/showthread.php?threadid=54443

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Finding all the values and storing them

There was a typo in tony's code (set rng1 twice instead of set rng2)

HTH
--
AP

'--------------------
Sub a()
Dim rng1 As Range
Dim rng2 As Range

Set rng1 = Worksheets("Sheet1").Range("A2")
Set rng2 = Worksheets("Sheet2").Range("A2")

Do
If rng1 = 61538 Then
rng2 = rng1.Offset(, 1)
Set rng2 = rng2.Offset(1)
End If

Set rng1 = rng1.Offset(1)
Loop Until rng1.Row = 100
MsgBox "done"
End Sub
'-------------------------
"jhahes" a écrit dans
le message de news: ...

the code isn't putting anything on Sheet2


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:
http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=544439



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding all the values and storing them


Thanks for sorting out the typo. I was in a bit of a rush last night an
didn't have time to test it.

Between a rock and a hard plac

--
tony
-----------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...fo&userid=2107
View this thread: http://www.excelforum.com/showthread.php?threadid=54443



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
Storing variable values in Excel worksheet Henry Stockbridge Excel Programming 3 April 25th 06 02:38 PM
excel storing previous cell values in memory Brent Bortnick Excel Worksheet Functions 2 April 19th 06 09:00 PM
Storing values to arrays for subsequent use Peter Rooney Excel Programming 3 July 29th 05 09:00 AM
Storing Values dinesh Excel Discussion (Misc queries) 0 June 10th 05 06:33 AM
Storing Cell Values in Access Mick Excel Programming 2 July 11th 04 09:34 AM


All times are GMT +1. The time now is 01:09 AM.

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"