Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default populate cell looking at last valued cell

I have two work books.

One workbook has 3 sheets, each a different company name.

The 2nd workbook is one sheet only. I have it set up so that the macro
selects a cell (example J5)

This is where I need the help..
The next step I want is to go back to the first workbook, select a specific
sheet, and then lookup the value in the last cell completed in row A and put
it in cell J5 from the 2nd workbook/sheet1.



--
Thanks for your help!

-Danielle
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default populate cell looking at last valued cell

For demo purposes only. Data will overwrite in WBw.Sh1."J5"
Should give you the general idea.

Sub cpynpst()
lr1 = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row 'last Row Col A
lr2 = Worksheets(2).Cells(Rows.Count, 1).End(xlUp).Row 'for each sheet
lr2 = Worksheets(3).Cells(Rows.Count, 1).End(xlUp).Row
With Workbooks(1)
.Worksheets(1).Range("A" & lr1).Copy Workbooks(2).Sheets(1).Range("J5")
.Worksheets(2).Range("A" & lr2).Copy Workbooks(2).Sheets(1).Range("J5")
.Worksheets(3).Range("A" & lr3).Copy Workbooks(2).Sheets(1).Range("J5")
End With
End Sub

"DanielleD" wrote:

I have two work books.

One workbook has 3 sheets, each a different company name.

The 2nd workbook is one sheet only. I have it set up so that the macro
selects a cell (example J5)

This is where I need the help..
The next step I want is to go back to the first workbook, select a specific
sheet, and then lookup the value in the last cell completed in row A and put
it in cell J5 from the 2nd workbook/sheet1.



--
Thanks for your help!

-Danielle

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default populate cell looking at last valued cell

This corrects typo:

Sub cpynpst()
lr1 = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row 'last Row Col A
lr2 = Worksheets(2).Cells(Rows.Count, 1).End(xlUp).Row 'for each sheet
lr3 = Worksheets(3).Cells(Rows.Count, 1).End(xlUp).Row
With Workbooks(1)
.Worksheets(1).Range("A" & lr1).Copy Workbooks(2).Sheets(1).Range("J5")
.Worksheets(2).Range("A" & lr2).Copy Workbooks(2).Sheets(1).Range("J5")
.Worksheets(3).Range("A" & lr3).Copy Workbooks(2).Sheets(1).Range("J5")
End With
End Sub

Also, you should use the names for workbooks(1) and (2)
and have both workbooks open when you run the code.
You should end up with the value of the last cell in sheet3
of WB(1) in WB(2).Sh2.Rng("J5") with this demo code.
You can modify it to apply to different sheets, cells etc.


"DanielleD" wrote:

I have two work books.

One workbook has 3 sheets, each a different company name.

The 2nd workbook is one sheet only. I have it set up so that the macro
selects a cell (example J5)

This is where I need the help..
The next step I want is to go back to the first workbook, select a specific
sheet, and then lookup the value in the last cell completed in row A and put
it in cell J5 from the 2nd workbook/sheet1.



--
Thanks for your help!

-Danielle

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
How to highlight the lowest valued cell in a column in Excel 2003 mapesii Excel Discussion (Misc queries) 2 December 11th 08 03:44 AM
How to populate a cell with numeric value based on textselected from pull down in adjacent cell? Garth Rodericks Excel Worksheet Functions 1 September 5th 08 02:03 AM
Populate a cell if values in cell 1 and cell 2 match cell 3 and 4 [email protected] Excel Worksheet Functions 1 August 22nd 08 02:04 AM
auto populate cell based on previous cell drop down list selectio. PuzzledbyLists Excel Discussion (Misc queries) 2 September 11th 06 01:28 AM
Conditionally formatting highest valued cell? brett Excel Worksheet Functions 10 December 22nd 05 08:30 AM


All times are GMT +1. The time now is 10:05 PM.

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"