LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default If cell 'a' matches cell 'b' then copy cell 'd' to cell 'e'

Since you are working between sheets, you will have to qualify your range
object statements by specifying the sheet for each object.

Sub cpynpst()
Set wks1 = Worksheets("Sheet1")
Set wks2 = Worksheets("Sheet2")
With wks1
If .Range("A1") = .Range("B2") Then
.Range("D1").Copy .Range("E1") ' <<<copies in same WS
End If
End With
If wks1.Range("A1") = wks1.Range("B2") Then
wks1.Range("D1").Copy wks2.Range("E1") '<< cpy to 2nd WS
End If
End Sub

When working between sheets, it is a good practice to qualify all of your
range objects (cell references and ranges) with their applicable worksheets.
That way VBA won't have to guess which one you really want to address.


"Marie" wrote:

Ok...... basically, I assume you answered my question..... problem is, I
don't know what to do with the answer. Would you please give 'idiot' proof
directions on how to proceed? Do I copy/paste everything from 'private
sub..........to end sub' into a cell and adjust it for my ranges? Then copy
it to each cell I need it to put the answer in? Do I put it somewhere in the
worksheet to execute under a macro key? I'm sorta lost here. I know just
enough to be dangerous. Please help out.

"GTVT06" wrote:

This worked for me... I just tested it on row 1, but it can be
adjusted for your needs

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("A1").Value = Range("B1").Value Then Range("D1").Copy
Range("E1")

End Sub

 
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
Returning Cell Value if Matches Another cell frankjh19701 Excel Worksheet Functions 5 February 13th 11 09:33 PM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell [email protected] Excel Worksheet Functions 2 November 7th 07 09:39 AM
if cell value matches then copy another cell billbeecham[_10_] Excel Programming 11 November 29th 05 08:46 AM


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