Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for pasteing to destination based on a cell value

I have a simple macro which copies the values from a set of cells, and
pastes them into a different sheet.
However I'm trying to change it so that the destination cell is
dependant on the value contain in a seperate cell.

For example:
I want to copy from 'A1' and paste to 'C1', but if the value of 'X1' =
1, I want to paste into 'C2' - If 'X1' = 2 then it pastes into 'C3'
etc.

The value range for X1 would only be between 1 and 5.

Any ideas you've got would be appreciated.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for pasteing to destination based on a cell value

Try this ....

=IF(X1=1,C1=A1,IF(X1=2,C2=A2, IF(X1=3,C3=A3,X1=0)))

----- daggra wrote: ----

I have a simple macro which copies the values from a set of cells, an
pastes them into a different sheet
However I'm trying to change it so that the destination cell i
dependant on the value contain in a seperate cell

For example:
I want to copy from 'A1' and paste to 'C1', but if the value of 'X1'
1, I want to paste into 'C2' - If 'X1' = 2 then it pastes into 'C3
etc

The value range for X1 would only be between 1 and 5

Any ideas you've got would be appreciated


--
Message posted from http://www.ExcelForum.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro for pasteing to destination based on a cell value

Not sure if I have this totally right, but look at the following:

Selection.Copy _
Destination:=Sheets("MySheet").Cells(Activesheet.R ange("X1")+1,3)

or
Selection.Copy _
Destination:=Sheets(2).Cells(Activesheet.Range("X1 ")+1,3)

You can replace Selection with Range("A1")
Change 'MySheet' or 2 to fit your situation.

Notice that this doesn't select the second sheet, just pastes there.

This uses Cells() instead of Range. Where Cells(1,1) = Range("A1")

hth
--
steveb
(Remove 'NOSPAM' from email address if replying direct)


"daggra " wrote in message
...
I have a simple macro which copies the values from a set of cells, and
pastes them into a different sheet.
However I'm trying to change it so that the destination cell is
dependant on the value contain in a seperate cell.

For example:
I want to copy from 'A1' and paste to 'C1', but if the value of 'X1' =
1, I want to paste into 'C2' - If 'X1' = 2 then it pastes into 'C3'
etc.

The value range for X1 would only be between 1 and 5.

Any ideas you've got would be appreciated.


---
Message posted from http://www.ExcelForum.com/



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
Macro changes formulas on destination worksheet Karen Excel Discussion (Misc queries) 2 August 12th 08 11:07 PM
Pasteing large amount of text to Excel merged cell outsol Excel Discussion (Misc queries) 0 February 22nd 08 05:41 PM
Pasteing formula gives blank result garin Excel Worksheet Functions 0 August 3rd 06 01:11 PM
keep a cell used in a formula constant when pasteing into another. Rob Excel Worksheet Functions 1 January 26th 05 07:21 PM
keep a cell used in a formula constant when pasteing into another. Rob Excel Worksheet Functions 1 January 26th 05 08:13 AM


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