Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default It's probably simple, but...

If anyone has the time to write sample code for the following, I would
appreciate it.

I would like to create a VB script in Microsoft Excel 2000.
The script needs to:
1. Look on a worksheet (Named B) in a specific cell (B1) for a value.
2. Find that same value on a different worksheet (Named A) in column A.
3. Then I run another script (already created and working) against the cell
location found in step 2.
4. This is repeated 170 times exactly. Each time I repeat, the cell location
on worksheet B changes. (B1, B2, B3...B170)

I do not know VB (trying to learn by doing), so even something as small as a
missing Dim could mess me up. Thanks in advance if anyone has the time to
help.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default It's probably simple, but...

Sub RunMeMany()
Dim cell as Range, rng as Range
Dim rng1 as Range, rng2 as Range
set rng = worksheets("B").Range("B1:B170")
Worksheets("A").Activate
set rng1 = Worksheets("A").Range("A1").Entirecolumn
for each cell in rng
res = Application.Match(cell.Value, _
rng1,0)
if not res is nothing then
set rng2 = rng1(res)
rng2.select
' your current code here
else
' color cell red if not found
cell.Interior.colorIndex = 3
end if
Next
End Sub

--
Regards,
Tom Ogilvy


"kmea" wrote in message
. ..
If anyone has the time to write sample code for the following, I would
appreciate it.

I would like to create a VB script in Microsoft Excel 2000.
The script needs to:
1. Look on a worksheet (Named B) in a specific cell (B1) for a value.
2. Find that same value on a different worksheet (Named A) in column A.
3. Then I run another script (already created and working) against the

cell
location found in step 2.
4. This is repeated 170 times exactly. Each time I repeat, the cell

location
on worksheet B changes. (B1, B2, B3...B170)

I do not know VB (trying to learn by doing), so even something as small as

a
missing Dim could mess me up. Thanks in advance if anyone has the time to
help.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default It's probably simple, but...

didn't dim res, so:
Sub RunMeMany()
Dim cell As Range, rng As Range
Dim rng1 As Range, rng2 As Range
Dim res As Variant
Set rng = Worksheets("B").Range("B1:B170")
Worksheets("A").Activate
Set rng1 = Worksheets("A").Range("A1").EntireColumn
For Each cell In rng
res = Application.Match(cell.Value, _
rng1, 0)
If Not res Is Nothing Then
Set rng2 = rng1(res)
rng2.Select
' you current code here
Else
' color cell red if not found
cell.Interior.ColorIndex = 3
End If
Next
End Sub

also, if the data you are looking for is a date, then you should do this:

Sub RunMeMany()
Dim cell As Range, rng As Range
Dim rng1 As Range, rng2 As Range
Dim res As Variant
Set rng = Worksheets("B").Range("B1:B170")
Worksheets("A").Activate
Set rng1 = Worksheets("A").Range("A1").EntireColumn
For Each cell In rng
res = Application.Match(clng(cell.Value2), _
rng1, 0)
If Not res Is Nothing Then
Set rng2 = rng1(res)
rng2.Select
' you current code here
Else
' color cell red if not found
cell.Interior.ColorIndex = 3
End If
Next
End Sub
"kmea" wrote in message
. ..
If anyone has the time to write sample code for the following, I would
appreciate it.

I would like to create a VB script in Microsoft Excel 2000.
The script needs to:
1. Look on a worksheet (Named B) in a specific cell (B1) for a value.
2. Find that same value on a different worksheet (Named A) in column A.
3. Then I run another script (already created and working) against the

cell
location found in step 2.
4. This is repeated 170 times exactly. Each time I repeat, the cell

location
on worksheet B changes. (B1, B2, B3...B170)

I do not know VB (trying to learn by doing), so even something as small as

a
missing Dim could mess me up. Thanks in advance if anyone has the time to
help.





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
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
Make it more simple or intuitive to do simple things Vernie Charts and Charting in Excel 1 March 16th 05 04:01 AM
simple question, hopefully a simple answer! Matt B Excel Programming 5 January 13th 04 08:43 PM


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