Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Test()
Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Book1") Set wb2 = Workbooks("Book2") Set findrng = wb2.Range("E1:E65536") x = WorksheetFunction.Match("Sale", findrng, 0) wb1.Worksheets("Sheet8").Range("C19").Value = Range(findrng.Item(x).Address).Offset(, -4).Value End Sub Mike F "Bob C" wrote in message ... Hi Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Many thanks Mike
Bob C -- Thank you Bob C It cost''''''''s little to carry knowledge with you. "Mike Fogleman" wrote: Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Book1") Set wb2 = Workbooks("Book2") Set findrng = wb2.Range("E1:E65536") x = WorksheetFunction.Match("Sale", findrng, 0) wb1.Worksheets("Sheet8").Range("C19").Value = Range(findrng.Item(x).Address).Offset(, -4).Value End Sub Mike F "Bob C" wrote in message ... Hi Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike
This is the code with correct W/book & sheet names inserted. It is copying Cell A5 on the same sheet into C19. Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Transactions.xls") Set wb2 = Workbooks("Statements.xls") Set findrng = wb2.Worksheets("Data").Range("E1:E65536") x = WorksheetFunction.Match("Salary", findrng, 0) wb1.Worksheets("Summary").Range("C19").Value = _ Range(findrng.Item(x).Address).Offset(0, -4).Value End Sub -- Thank you Bob C It cost''''''''s little to carry knowledge with you. "Mike Fogleman" wrote: Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Book1") Set wb2 = Workbooks("Book2") Set findrng = wb2.Range("E1:E65536") x = WorksheetFunction.Match("Sale", findrng, 0) wb1.Worksheets("Sheet8").Range("C19").Value = Range(findrng.Item(x).Address).Offset(, -4).Value End Sub Mike F "Bob C" wrote in message ... Hi Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the update, glad it's working. As you can see, Copy/Paste is not
necessary to duplicate data. Just assign the value to the range. Reserve Copy/Paste functions for transferring things like cell formatting or filtered lists, etc. Mike F "Bob C" wrote in message ... Mike This is the code with correct W/book & sheet names inserted. It is copying Cell A5 on the same sheet into C19. Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Transactions.xls") Set wb2 = Workbooks("Statements.xls") Set findrng = wb2.Worksheets("Data").Range("E1:E65536") x = WorksheetFunction.Match("Salary", findrng, 0) wb1.Worksheets("Summary").Range("C19").Value = _ Range(findrng.Item(x).Address).Offset(0, -4).Value End Sub -- Thank you Bob C It cost''''''''s little to carry knowledge with you. "Mike Fogleman" wrote: Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Book1") Set wb2 = Workbooks("Book2") Set findrng = wb2.Range("E1:E65536") x = WorksheetFunction.Match("Sale", findrng, 0) wb1.Worksheets("Sheet8").Range("C19").Value = Range(findrng.Item(x).Address).Offset(, -4).Value End Sub Mike F "Bob C" wrote in message ... Hi Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike it's not working.
It's not getting the offset value from Column A in wb2. It just copies cell A5 in wb1 to cell c19 in the same wb1. It's not referencing wb2 at all. Sorry for my second post it looked OK but I had not tested. Bob C It cost's little to carry knowledge with you. "Mike Fogleman" wrote: Thanks for the update, glad it's working. As you can see, Copy/Paste is not necessary to duplicate data. Just assign the value to the range. Reserve Copy/Paste functions for transferring things like cell formatting or filtered lists, etc. Mike F "Bob C" wrote in message ... Mike This is the code with correct W/book & sheet names inserted. It is copying Cell A5 on the same sheet into C19. Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Transactions.xls") Set wb2 = Workbooks("Statements.xls") Set findrng = wb2.Worksheets("Data").Range("E1:E65536") x = WorksheetFunction.Match("Salary", findrng, 0) wb1.Worksheets("Summary").Range("C19").Value = _ Range(findrng.Item(x).Address).Offset(0, -4).Value End Sub -- Thank you Bob C It cost''''''''s little to carry knowledge with you. "Mike Fogleman" wrote: Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Book1") Set wb2 = Workbooks("Book2") Set findrng = wb2.Range("E1:E65536") x = WorksheetFunction.Match("Sale", findrng, 0) wb1.Worksheets("Sheet8").Range("C19").Value = Range(findrng.Item(x).Address).Offset(, -4).Value End Sub Mike F "Bob C" wrote in message ... Hi Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are right, I didn't test it either (shame on me). I didn't qualify wb2
as the source: Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Transactions.xls") Set wb2 = Workbooks("Statements.xls") Set findrng = wb2.Worksheets("Data").Range("E1:E65536") x = WorksheetFunction.Match("Salary", findrng, 0) wb1.Worksheets("Summary").Range("C19").Value = _ wb2.Range(findrng.Item(x).Address).Offset(0, -4).Value End Sub Mike F "Bob C" wrote in message ... Mike it's not working. It's not getting the offset value from Column A in wb2. It just copies cell A5 in wb1 to cell c19 in the same wb1. It's not referencing wb2 at all. Sorry for my second post it looked OK but I had not tested. Bob C It cost's little to carry knowledge with you. "Mike Fogleman" wrote: Thanks for the update, glad it's working. As you can see, Copy/Paste is not necessary to duplicate data. Just assign the value to the range. Reserve Copy/Paste functions for transferring things like cell formatting or filtered lists, etc. Mike F "Bob C" wrote in message ... Mike This is the code with correct W/book & sheet names inserted. It is copying Cell A5 on the same sheet into C19. Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Transactions.xls") Set wb2 = Workbooks("Statements.xls") Set findrng = wb2.Worksheets("Data").Range("E1:E65536") x = WorksheetFunction.Match("Salary", findrng, 0) wb1.Worksheets("Summary").Range("C19").Value = _ Range(findrng.Item(x).Address).Offset(0, -4).Value End Sub -- Thank you Bob C It cost''''''''s little to carry knowledge with you. "Mike Fogleman" wrote: Sub Test() Dim wb1 As Workbook, wb2 As Workbook Dim x As Integer Dim findrng As Range Set wb1 = Workbooks("Book1") Set wb2 = Workbooks("Book2") Set findrng = wb2.Range("E1:E65536") x = WorksheetFunction.Match("Sale", findrng, 0) wb1.Worksheets("Sheet8").Range("C19").Value = Range(findrng.Item(x).Address).Offset(, -4).Value End Sub Mike F "Bob C" wrote in message ... Hi Using Office 2003 I'm trying to find in W/book2, Sheet1 Column E the first row containing the word Sale. Then in Column A same row, copy cells date value and paste value into W/book1 Sheet8 cell C19. TIA -- Thank you Bob C It cost''s little to carry knowledge with you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA - Testing for Book1, Book2 etc. | Excel Discussion (Misc queries) | |||
Book1 and Book2 | Excel Discussion (Misc queries) | |||
=SUMIF(book2!L3:AF3, "=book1!O30", book2!L20:AF20) | Excel Discussion (Misc queries) | |||
run macro in book1 from book2 - how? | Excel Programming | |||
IE to Book1, to book2, then close Book1.xls | Excel Programming |