LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Bit of a VBA problem.


Hello all,

I'm trying to write up a macro for excel to streamline some things I
have to do regularly, but this one is giving me a bit of trouble. I
don't think it is too complicated, I could probably do it in C++
easily, but VBA is always iffy with me. Luckily, with some help from
others, I got most of it written but I am having a small problem
still.

First some background:
I have two workbooks, each with 1 sheet in them.

'WorkbookA.xls|Sheet1' is more or less static list but it may have
additional entries from month to month (think of it as a 'flag it'
list). It essentially contains information about things. The names are

all in column A (lets say down to 100 for simplicity's sake). The
locations are in column B.


Code:
--------------------
Example:
1) Column A Column B

2) Person A CHARLOTTE
3) Person B JACKSONVILLE
4) Person C HALIFAX

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


'WorkbookB.xls|Sheet1' has a rather large list of transactions which
get assigned an ID in column A by a macro we already have in place. The

names are in column C. The locations are in column D


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

Example:
1) A B C D


2) 123 Contact A Person A CHARLOTTE (More info)
3) 123 Contact A Person B JACKSONVILLE (More info)
4) 225 Contact B Person A CHARLOTTE (More info)
5) 225 Contact B Person D LOS ANGELES (More info)
6) 334 Contact C Person C HALIFAX (More info)


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


However, Workbook B does not account for any of the 'flagged' items in

workbook A. In the above Workbook B example, rows 2,3,4, and 6 should
be flagged.

So I need this macro to take the data from column A in the
first workbook, and run it through Workbook B (column C). If it were to

find a match, it should change Workbook B (Column A) to another ID
value (lets say
5000).
For simplicity, only name matching was done at first, here is the code
thus far:

Code:
--------------------
Dim rngA as Range, rngB as Range, rng as Range
Dim cell as Range, sAddr as String
with workbooks("WorkbookA.xls").Worksheets("Sheet1")
set rngA = .range(.Cells(1,1),.Cells(1,1).end(xldown))
End with
With workbooks("WorkbookB.xls").Worksheets("Sheet1")
set rngB = .Range(.Cells(1,3),.Cells(1,3).End(xldown))
End with
for each cell in rngA
set rng = rngB.Find(What:=cell.Value, _
After:=rngB(rngB.count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
if not rng is nothing then
sAddr = rng
do
if rng.offset(0,1).Value = _
cell.offset(0,1).Value then
cell.offset(0,-2).Value = 5000
end if
set rng = rngB.FindNext(rng)
loop until rng.Address = sAddr
End if
Next
--------------------


I get errors on the following line:
cell.offset(0,-2).Value = 5000

Any ideas?

Thanks for your help.


--
mazzarin
------------------------------------------------------------------------
mazzarin's Profile: http://www.excelforum.com/member.php...o&userid=32186
View this thread: http://www.excelforum.com/showthread...hreadid=519316

 
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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


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