#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macros


I have a list of data on sheet 2. Each time a figure occurs for a nam
matching the one on sheet 1 I want this figure to be inserted ont
sheet 1 as the most recent figure (i.e. shifting all cells in the ro
to the right). Each name occurs multiple times on sheet two and thus
need the macro to read work through the list on sheet 2 updating as i
works rather than after it finishes.
Is this possible?

Thanks very much

Phi

--
phil200
-----------------------------------------------------------------------
phil2006's Profile: http://www.excelforum.com/member.php...fo&userid=3509
View this thread: http://www.excelforum.com/showthread.php?threadid=54943

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macros

On sheet2, assume the list of names is in column 1 starting in A1. The
figure is in column B adjacent to the name

The name to search for originates in A1 of sheet1

Dim sh as worksheet, nm as String
Dim rng as Range, cell as Range
set sh = worksheets("sheet1")
nm = sh.range("A1").Value
with worksheets("Sheet2")
set rng = .range(.cells(1,1),.cells(1,1).end(xldown))
End with
for each cell in rng
if cell.value = nm
sh.columns(1).Insert
sh.Range("A1").Value = cell.offset(0,1).vlaue
end if
Next

Perhaps the above will give you a start.

--
Regards,
Tom Ogilvy



"phil2006" wrote:


I have a list of data on sheet 2. Each time a figure occurs for a name
matching the one on sheet 1 I want this figure to be inserted onto
sheet 1 as the most recent figure (i.e. shifting all cells in the row
to the right). Each name occurs multiple times on sheet two and thus I
need the macro to read work through the list on sheet 2 updating as it
works rather than after it finishes.
Is this possible?

Thanks very much

Phil


--
phil2006
------------------------------------------------------------------------
phil2006's Profile: http://www.excelforum.com/member.php...o&userid=35092
View this thread: http://www.excelforum.com/showthread...hreadid=549433


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macros


Thanks! I still don't quite understand where I put this into tho? I
this the macro? Please excuse my ignorance

--
phil200
-----------------------------------------------------------------------
phil2006's Profile: http://www.excelforum.com/member.php...fo&userid=3509
View this thread: http://www.excelforum.com/showthread.php?threadid=54943

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default macros

That is the essential code of the macro. You need to name it

Sub MyMacro()
Dim sh as worksheet, nm as String
Dim rng as Range, cell as Range
set sh = worksheets("sheet1")
nm = sh.range("A1").Value
with worksheets("Sheet2")
set rng = .range(.cells(1,1),.cells(1,1).end(xldown))
End with
for each cell in rng
if cell.value = nm
sh.columns(1).Insert
sh.Range("A1").Value = cell.offset(0,1).vlaue
end if
Next
End Sub

You need to do Alt+F11 to get to the vbe, then do Insert =Module in the
menu there and then paste the code into that module.

http://www.mvps.org/dmcritchie/excel/getstarted.htm

http://www.mvps.org/dmcritchie/excel....htm#tutorials
vba tutorials listed after the excel tutorials.

--
Regards,
Tom Ogilvy


"phil2006" wrote:


Thanks! I still don't quite understand where I put this into tho? Is
this the macro? Please excuse my ignorance!


--
phil2006
------------------------------------------------------------------------
phil2006's Profile: http://www.excelforum.com/member.php...o&userid=35092
View this thread: http://www.excelforum.com/showthread...hreadid=549433


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default macros

I think Tom posted his answer to someone else's question here.


"Tom Ogilvy" wrote in message
...
That is the essential code of the macro. You need to name it

Sub MyMacro()
Dim sh as worksheet, nm as String
Dim rng as Range, cell as Range
set sh = worksheets("sheet1")
nm = sh.range("A1").Value
with worksheets("Sheet2")
set rng = .range(.cells(1,1),.cells(1,1).end(xldown))
End with
for each cell in rng
if cell.value = nm
sh.columns(1).Insert
sh.Range("A1").Value = cell.offset(0,1).vlaue
end if
Next
End Sub

You need to do Alt+F11 to get to the vbe, then do Insert =Module in the
menu there and then paste the code into that module.

http://www.mvps.org/dmcritchie/excel/getstarted.htm

http://www.mvps.org/dmcritchie/excel....htm#tutorials
vba tutorials listed after the excel tutorials.

--
Regards,
Tom Ogilvy


"phil2006" wrote:


Thanks! I still don't quite understand where I put this into tho? Is
this the macro? Please excuse my ignorance!


--
phil2006
------------------------------------------------------------------------
phil2006's Profile:
http://www.excelforum.com/member.php...o&userid=35092
View this thread:
http://www.excelforum.com/showthread...hreadid=549433




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
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Macros inside macros, and pasting into macro code. pagelocator[_2_] Excel Programming 1 November 24th 04 09:11 AM
convert lotus 123w macros to excel macros rpiescik Excel Programming 1 September 18th 04 01:35 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM


All times are GMT +1. The time now is 11:23 PM.

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"