Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I write macro to copy the value of a cell to another if va.

How do I write a macro to copy the value of cell A1, B1, C1 of sheet1 to
E1,F1 & G1 of sheet2 respectively if the value of cell A1 of sheet2 is equal
to the value of cell B1of sheet1?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default how do I write macro to copy the value of a cell to another if va.

If you want to run it manually (or from another macro) then use this.....

Sub copy()
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")

If sh2.Range("A1").Value = sh1.Range("B1").Value Then
sh2.Range("E1").Value = sh1.Range("A1").Value
sh2.Range("F1").Value = sh1.Range("B1").Value
sh2.Range("G1").Value = sh1.Range("C1").Value
End If
End Sub

If you need to make it to sense the change in the cells that set the
condition then you need to trap worksheet events - repost here for support.

--
Cheers
Nigel



"Prabhu" wrote in message
...
How do I write a macro to copy the value of cell A1, B1, C1 of sheet1 to
E1,F1 & G1 of sheet2 respectively if the value of cell A1 of sheet2 is

equal
to the value of cell B1of sheet1?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default how do I write macro to copy the value of a cell to another if va.

You don't need a macro

Sheet2!E1: = IF(A1=Sheet1!B1,Sheet1!A1,"")

etc.

--
HTH

Bob Phillips

"Prabhu" wrote in message
...
How do I write a macro to copy the value of cell A1, B1, C1 of sheet1 to
E1,F1 & G1 of sheet2 respectively if the value of cell A1 of sheet2 is

equal
to the value of cell B1of sheet1?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default how do I write macro to copy the value of a cell to another if va.

This is a good example of the value of the discussion group. If the data is
updated frequently, then Bob Phillips solution is good because €śthe result€ť
responds automatically to the updates. If €śthe result€ť needs to be exported,
then Nigels solution is good because it produces a snapshot with no links to
remove.
--
Gary's Student


"Prabhu" wrote:

How do I write a macro to copy the value of cell A1, B1, C1 of sheet1 to
E1,F1 & G1 of sheet2 respectively if the value of cell A1 of sheet2 is equal
to the value of cell B1of sheet1?

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
write a copy/paste from one workbook to another in a macro Jennrl Excel Discussion (Misc queries) 1 August 7th 09 10:37 PM
Saving a copy of excel file in macro but have it auto write pano Excel Worksheet Functions 4 March 27th 07 11:54 PM
How to write a simple copy-paste macro? R. H. Rosenberg New Users to Excel 4 November 25th 06 12:26 AM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Write a macro ro copy column at certain time of day. Daytrader Excel Programming 2 February 2nd 04 05:28 AM


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