Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Unfortunately I am not completely clear on how you are laying out the information in the Amount spreadsheet, so I have assumed that column A contains something like "Total 11111" and the total will be inserted in to Column B. Here is a small sample that demonstrates this (it assumes that the workbooks are open etc): Sub Replace() Dim IDRange As Range Dim AmountRange As Range Dim cell As Range 'Identify range containing ID's Set IDRange = Workbooks("Id.xls").Sheets("Sheet1").Range("A1") Set IDRange = Range(IDRange, IDRange.End(xlDown)) 'Identify range containing Summary Data Set AmountRange = Workbooks("Amount.xks").Sheets("Sheet1").Range("A1 ") Set AmountRange = Range(AmountRange, AmountRange.End(xlDown)) 'Loop through For Each cell In IDRange InsertAmount AmountRange, cell Next End Sub Sub InsertAmount(RangeToSearch As Range, IDRange As Range) Dim MatchRange As Range Dim strid As String On Error GoTo done 'Get text of Id strid = Trim(Str(IDRange)) 'Search for range containing the Id Set MatchRange = RangeToSearch.Find(strid) 'Put value to the right of the id in the cell to the right of the matching range MatchRange.Offset(0, 1).Value = IDRange.Offset(0, 1).Value done: End Sub Hope this helps! Regards Jane Pratt Developer Tools Support Microsoft UK This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find and Replace with formated data | Excel Worksheet Functions | |||
find and replace data | Excel Worksheet Functions | |||
find and replace - replace data in rows to separated by commas | Excel Worksheet Functions | |||
How to find/replace data in column | Excel Discussion (Misc queries) | |||
How to find/replace data in column | New Users to Excel |