Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default pasting and Ifelse function


ok i want my macro to:

1)copy (from "wages" sheet) and paste one value into one cell (c12 in
"ast")

2)then for excel to open another sheet ("gates") and if "A1" is the
name i want it to be i want excel to copy "b2" into "C4" in "ast"

so far i got

Sheets("prem_wages").Select
Range("B2").Select
Selection.Copy
Sheets("ast").Select
Range("C12").Select

which i know will copy and select what i want for the first bit, but
how do i get it to then paste it in for me?

And for the second point i am not sure where to start cause the data i
get will look summat like this each week:

Newcastle 42000 Blackburn
blues 42000 Man utd
Boro 13000 Sheff utd
aston_villa 1000 Arsenal

I'd imagine it was some thing like:

Sheets("prem_gates").Select
If (A1) = aston_villa then
Range("B1").Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select
else
If (A2) = aston_villa then
Range(b2).Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select
else
If (A3) = aston_villa then
Range("B3").Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select
else
If (A4) = aston_villa then
Range("B4").Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select

Obviously i am probably wrong but if some one could help with either
problem it would be great :)

Alex


--
B_Carpet
------------------------------------------------------------------------
B_Carpet's Profile: http://www.excelforum.com/member.php...o&userid=20207
View this thread: http://www.excelforum.com/showthread...hreadid=389754

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default pasting and Ifelse function

Not sure I understand your problem but I assume you got your data in Sheet
"prem_wages" starting in the "A" cloumn and also that sheet "ast" is in the
same workbook as "prem_wages".

If so this macro may be one way of solving your problem. I also assume that
there is only one "aston_villa" value in your data set.


Sub paste_value()
'
Dim MyRange As Range, Cell As Range

Sheets("prem_wages").Activate (This line can be removed if "prem_wages"
always is the active sheet)

Set MyRange = Range(Range("A1"), Cells(Rows.Count, 1).End(xlUp))

For Each Cell In MyRange

If Cell.Text = "aston_villa" Then

Range("ast!C4").Value = Cell.Offset(0, 1).Value

End If

Next Cell

End Sub


"B_Carpet" wrote in
message ...

ok i want my macro to:

1)copy (from "wages" sheet) and paste one value into one cell (c12 in
"ast")

2)then for excel to open another sheet ("gates") and if "A1" is the
name i want it to be i want excel to copy "b2" into "C4" in "ast"

so far i got

Sheets("prem_wages").Select
Range("B2").Select
Selection.Copy
Sheets("ast").Select
Range("C12").Select

which i know will copy and select what i want for the first bit, but
how do i get it to then paste it in for me?

And for the second point i am not sure where to start cause the data i
get will look summat like this each week:

Newcastle 42000 Blackburn
blues 42000 Man utd
Boro 13000 Sheff utd
aston_villa 1000 Arsenal

I'd imagine it was some thing like:

Sheets("prem_gates").Select
If (A1) = aston_villa then
Range("B1").Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select
else
If (A2) = aston_villa then
Range(b2).Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select
else
If (A3) = aston_villa then
Range("B3").Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select
else
If (A4) = aston_villa then
Range("B4").Select
Selection.Copy
Sheets("ast").Select
Range("C4").Select

Obviously i am probably wrong but if some one could help with either
problem it would be great :)

Alex


--
B_Carpet
------------------------------------------------------------------------
B_Carpet's Profile:
http://www.excelforum.com/member.php...o&userid=20207
View this thread: http://www.excelforum.com/showthread...hreadid=389754



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
How to stop Paste Link function from pasting an object michelle Excel Discussion (Misc queries) 1 November 2nd 06 04:51 PM
Paste function is greyed out in the toolbar and I can't use ctl V - worksheet won't allow pasting Bob Reynolds Excel Discussion (Misc queries) 3 December 15th 05 03:24 PM
IFELSE question, as it applies to multiple cells JTF Excel Programming 3 May 2nd 05 08:33 PM
Sum function when pasting Matt Excel Worksheet Functions 2 March 14th 05 02:30 PM
Pasting a worksheet function in VBA. Jako[_64_] Excel Programming 1 August 6th 04 10:45 PM


All times are GMT +1. The time now is 05:45 AM.

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"