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's with if function included

I am trying to write a macro that takes a set of data, pastes special the
data depending on what month the column displays with some sort of if
function. Is it possible to do this and how do i do it.

E.g.
Input:
Jan Jan Feb Mar April
13 x
23 x
28 x

As above when the data is placed in Jan i would like it to paste special the
data in the Jan column (displayed with X). However if the name aboe the
input data was changed to Feb i would like it to place the data in Feb.

Thanks in advance for anyone's help...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default macro's with if function included

Right click sheet tabview codeinsert this. Be advised that it will copy
the whole column to col A.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$A$1" Then Exit Sub
mc = Rows(1).Find(What:=Target, After:=Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
Columns(mc).Copy Columns(1)
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Josh" <Josh @discussions.microsoft.com wrote in message
...
I am trying to write a macro that takes a set of data, pastes special the
data depending on what month the column displays with some sort of if
function. Is it possible to do this and how do i do it.

E.g.
Input:
Jan Jan Feb Mar
April
13 x
23 x
28 x

As above when the data is placed in Jan i would like it to paste special
the
data in the Jan column (displayed with X). However if the name aboe the
input data was changed to Feb i would like it to place the data in Feb.

Thanks in advance for anyone's help...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default macro's with if function included

Try this small macro:

Sub marine()
v = Range("A1").Value
n = Cells(Rows.Count, "A").End(xlUp).Row
Set cpr = Range("A2:A" & n)
For i = 2 To Columns.Count
If v = Cells(1, i).Value Then
Exit For
End If
Next
cpr.Copy
Cells(2, i).PasteSpecial Paste:=xlPasteValues
End Sub

--
Gary''s Student - gsnu200813


"Josh" wrote:

I am trying to write a macro that takes a set of data, pastes special the
data depending on what month the column displays with some sort of if
function. Is it possible to do this and how do i do it.

E.g.
Input:
Jan Jan Feb Mar April
13 x
23 x
28 x

As above when the data is placed in Jan i would like it to paste special the
data in the Jan column (displayed with X). However if the name aboe the
input data was changed to Feb i would like it to place the data in Feb.

Thanks in advance for anyone's help...

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 FUNCTION conflict with other macro's MrDave Excel Discussion (Misc queries) 3 July 19th 09 12:25 PM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
Having a cell with '<' sign included within a function? Michelle Excel Discussion (Misc queries) 2 December 5th 05 10:50 PM


All times are GMT +1. The time now is 09:52 AM.

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"