Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Value to another sheet with Macro


Hello,

I have a list of 10 names on sheet1 in column A. Column B had monetar
values besides the names.

Sheet2 has those same names in column A. Row 1 uptop has dates space
apart every 7 days.

I need a macro to find a name from sheet1, look on sheet 2 for th
matching name, then place its value in the next empty column. Hit th
button again, and it places the value in the next column. See Exampl
below:

Sheet 1 (this week):

A B
1 Mark $50
2 Paul $25
3 Sally $15

Next Week things has changed...

Sheet1 (next week):

A B
1 Mark $20
2 Paul $80
3 Sally $35


Sheet 2 (which is the DataBase):

A B C
1 Mark $50 $20
2 Paul $25 $80
3 Sally $15 $35

Note: I should be able to add more names if necessary to the sheet

Thanks,
EMo

--
EMo
-----------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...fo&userid=2318
View this thread: http://www.excelforum.com/showthread.php?threadid=37505

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Transfer Value to another sheet with Macro

In my opinion you should re-evaluate how you want to do this. The path you
are going down will be problematic. My recomendation would be (as you even
suggest) to make this more like a database. Sheet 1 should be 3 columns
instead of two. New records will be appended to the end of the list. The
third column will be the date. You can then just create a pivot table on
sheet 2 referencing the source data on sheet 1. You will be able to get your
weeks across the top and the people down the side... No macros... Easy to
do...
--
HTH...

Jim Thomlinson


"EMoe" wrote:


Hello,

I have a list of 10 names on sheet1 in column A. Column B had monetary
values besides the names.

Sheet2 has those same names in column A. Row 1 uptop has dates spaced
apart every 7 days.

I need a macro to find a name from sheet1, look on sheet 2 for the
matching name, then place its value in the next empty column. Hit the
button again, and it places the value in the next column. See Example
below:

Sheet 1 (this week):

A B
1 Mark $50
2 Paul $25
3 Sally $15

Next Week things has changed...

Sheet1 (next week):

A B
1 Mark $20
2 Paul $80
3 Sally $35


Sheet 2 (which is the DataBase):

A B C
1 Mark $50 $20
2 Paul $25 $80
3 Sally $15 $35

Note: I should be able to add more names if necessary to the sheet

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=375050


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Value to another sheet with Macro


Try this macro


Sub macro()
Dim i, name, monet As Variant
i = 2
Worksheets("Sheet1").Select
While Range("a" & i).Value < ""
name = Range("a" & i).Value
monet = Range("b" & i).Value
Worksheets("Sheet2").Select
Columns("A:A").Select
On Error GoTo a:
Selection.Find(What:=name, After:=ActiveCell
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
_
MatchCase:=False).Activate
temp = ActiveCell.Address
ActiveCell.Select
Selection.End(xlToRight).Select
If ActiveCell.Column = 256 Then
Range(temp).Offset(0, 1).Select
Else
ActiveCell.Offset(0, 1).Select
End If
ActiveCell.Value = monet
a:
If (Err.Description < "") Then
Err.Clear
End If
Worksheets("Sheet1").Select
i = i + 1
Wend
End Su

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=37505

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Value to another sheet with Macro


The code works well.

I see that it finds the next blank cell, then fills it. So if I ad
another name after about 5 transfers. It will add that amount to th
first blank cell, and not over to the 6th transfer column.

But it still works for me. I just fill the empty cells with 0'
(conditional formatted to white text color, so that they're invisible
so that the code goes to the correct column which has the correc
date.

Thanks,
EMo

--
EMo
-----------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...fo&userid=2318
View this thread: http://www.excelforum.com/showthread.php?threadid=37505

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Transfer Value to another sheet with Macro

If you do want to do this, this will do it. It compensates for adding a
name, adds 7 days to the date, copies the values.

Sub copytolastcol()
With Sheets("yourdestinationsheetname")
Range("a2:a20").Copy .Range("a2")'copies names
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
..Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7'adds date
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
..Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

--
Don Guillett
SalesAid Software

"EMoe" wrote in message
...

Hello,

I have a list of 10 names on sheet1 in column A. Column B had monetary
values besides the names.

Sheet2 has those same names in column A. Row 1 uptop has dates spaced
apart every 7 days.

I need a macro to find a name from sheet1, look on sheet 2 for the
matching name, then place its value in the next empty column. Hit the
button again, and it places the value in the next column. See Example
below:

Sheet 1 (this week):

A B
1 Mark $50
2 Paul $25
3 Sally $15

Next Week things has changed...

Sheet1 (next week):

A B
1 Mark $20
2 Paul $80
3 Sally $35


Sheet 2 (which is the DataBase):

A B C
1 Mark $50 $20
2 Paul $25 $80
3 Sally $15 $35

Note: I should be able to add more names if necessary to the sheet

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=375050





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Value to another sheet with Macro


Thanks for the reply!

Sub copytolastcol()
With Sheets("yourdestinationsheetname")
Range("a2:a20").Copy .Range("a2")'copies names
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
.Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7'adds date
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
.Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

Yes I really want to do this, with the option of adding new names. Whe
I run the code, I get "Compile error, Argument not optional, and exce
highlights lastcol =

I haven't a clue whats wrong. I placed the code in a module, as well a
in This Workbook. Still not working.

EMo

--
EMo
-----------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...fo&userid=2318
View this thread: http://www.excelforum.com/showthread.php?threadid=37505

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Transfer Value to another sheet with Macro

I thought you needed a "." in front of any objects which have a parent = to
the item you referenced using "With"

Sorry if not helpful, I am sure someone will be more helpful.

"EMoe" wrote in message
...

Thanks for the reply!

Sub copytolastcol()
With Sheets("yourdestinationsheetname")
Range("a2:a20").Copy .Range("a2")'copies names
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7'adds date
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

Yes I really want to do this, with the option of adding new names. When
I run the code, I get "Compile error, Argument not optional, and excel
highlights lastcol =

I haven't a clue whats wrong. I placed the code in a module, as well as
in This Workbook. Still not working.

EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:
http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=375050



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Transfer Value to another sheet with Macro

this is what I TESTED and sent with all .'s in the right place. Have no idea
why some were deleted?

Sub copytolastcol()
With Sheets("sheet2")
Range("a2:a10").Copy .Range("a2")
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
.Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
.Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

--
Don Guillett
SalesAid Software

"William Benson" wrote in message
...
I thought you needed a "." in front of any objects which have a parent =

to
the item you referenced using "With"

Sorry if not helpful, I am sure someone will be more helpful.

"EMoe" wrote in

message
...

Thanks for the reply!

Sub copytolastcol()
With Sheets("yourdestinationsheetname")
Range("a2:a20").Copy .Range("a2")'copies names
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7'adds date
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

Yes I really want to do this, with the option of adding new names. When
I run the code, I get "Compile error, Argument not optional, and excel
highlights lastcol =

I haven't a clue whats wrong. I placed the code in a module, as well as
in This Workbook. Still not working.

EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:
http://www.excelforum.com/member.php...o&userid=23183
View this thread:

http://www.excelforum.com/showthread...hreadid=375050





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Transfer Value to another sheet with Macro

I did not get any error except that lastcol wasn't declared (so I remove
option explicit) and then it ran...


"Don Guillett" wrote in message
...
this is what I TESTED and sent with all .'s in the right place. Have no
idea
why some were deleted?

Sub copytolastcol()
With Sheets("sheet2")
Range("a2:a10").Copy .Range("a2")
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
.Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
.Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

--
Don Guillett
SalesAid Software

"William Benson" wrote in message
...
I thought you needed a "." in front of any objects which have a parent =

to
the item you referenced using "With"

Sorry if not helpful, I am sure someone will be more helpful.

"EMoe" wrote in

message
...

Thanks for the reply!

Sub copytolastcol()
With Sheets("yourdestinationsheetname")
Range("a2:a20").Copy .Range("a2")'copies names
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7'adds date
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub

Yes I really want to do this, with the option of adding new names. When
I run the code, I get "Compile error, Argument not optional, and excel
highlights lastcol =

I haven't a clue whats wrong. I placed the code in a module, as well as
in This Workbook. Still not working.

EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:
http://www.excelforum.com/member.php...o&userid=23183
View this thread:

http://www.excelforum.com/showthread...hreadid=375050







  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Value to another sheet with Macro


I find one problem with this code. If you format the cells (e.g. with
currency or even with borders) the code skips those cells, and goes to
the next one. If you try to delete the formats, the code still
continues to the next cell.

Code:


Sub copytolastcol()
With Sheets("sheet2")
Range("a2:a10").Copy .Range("a2")
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
..Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
..Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub


How can you help?

Thanks,
ME


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=375050



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Transfer Value to another sheet with Macro

This code does not skip formatting, it simply ignores it since you only
asked to copy the values. If you want the formatting you will need to use
copy/paste special

Sub copytolastcol()
Application.ScreenUpdating = False
With Sheets("sheet2")
Range("a2:a10").Copy .Range("a2")
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
..Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
'=====
Cells(c.Row, 2).Copy
..Cells(x, lastcol + 1).PasteSpecial Paste:=xlPasteAll
'=====
'instead of
'.Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
Application.ScreenUpdating = False
End Sub


--
Don Guillett
SalesAid Software

"EMoe" wrote in message
...

I find one problem with this code. If you format the cells (e.g. with
currency or even with borders) the code skips those cells, and goes to
the next one. If you try to delete the formats, the code still
continues to the next cell.

Code:


Sub copytolastcol()
With Sheets("sheet2")
Range("a2:a10").Copy .Range("a2")
lastcol = .Cells.SpecialCells(xlCellTypeLastCell).Column
Cells(1, lastcol + 1) = .Cells(1, lastcol) + 7
For Each c In Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row)
x = .Columns(1).Find(c).Row
Cells(x, lastcol + 1).Value = Cells(c.Row, 2)
Next
End With
End Sub


How can you help?

Thanks,
ME


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=375050



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Value to another sheet with Macro


Excellent!!!

This code does exactly what I need.

Regards,
EMo

--
EMo
-----------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...fo&userid=2318
View this thread: http://www.excelforum.com/showthread.php?threadid=37505

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
transfer datas into different sheet using macro? joana0907 Excel Discussion (Misc queries) 2 April 29th 09 09:45 AM
transfer contents from a cell in previous sheet if the sheet is a DarkNight New Users to Excel 1 September 9th 08 01:04 AM
How can I transfer a required data from sheet 1 to sheet 2 automat Malik Nadeem Excel Discussion (Misc queries) 6 October 24th 07 11:48 AM
How to Automatically transfer specific Data from Sheet 1 to Sheet Jman Excel Worksheet Functions 12 May 10th 07 05:35 AM
Transfer/Copy Sheet, Dynamically linked Sheet 0-0 Wai Wai ^-^ Excel Discussion (Misc queries) 2 December 23rd 05 10:04 PM


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