emhotep
11-29-2011, 05:11 AM
Hi guys
I have only been working with excel macros for 1 week so I am sorry if I write nonsense.
I now have a working macro but it is 1500 lines long because of the huge amount of possibilities of where to place the value of a copied cell.
Maybe you guys could be so kind to help me with the correct code.
It is (for me that is) simple:
Copy value from cells a1:d1
Paste it in sheet / cell
(this is the variable, in cell AL20 the sheet returns a cell ref depending of a selection in the sheet and there are 150 different possibilities) I need the macro to place the copied value en the cell specified in AL20 always checking first, what the value is.
Is that possible? Can you write the code? Will you help me please?
Thank you very much
This is the start of my macro as I found out to make it.
Sub PlaceSingleScores()
'
' Makro Place Singles Results
'
'Copy end destination from vlookup to next cell and paste value only
'
Sheets("Principal").Select
Range("AL19").Copy
Range("AL20").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
' Copy score one down value only
'
Range("Ao22:ar22").Copy
Range("ao23:ar23").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
' START actual macro
'
Range("$ao$23:$ar$23").Select
selection.Copy
If Range("$AL$19").Value = ("F6") Then
Sheets("Resultados Individuales").Select
Range("F6:i6").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Principal").Select
Range("b6").Select
ElseIf Range("$AL$19").Value = ("J6") Then
Sheets("Resultados Individuales").Select
Range("j6:m6").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Principal").Select
Range("b6").Select
ElseIf Range("$AL$19").Value = ("N6") Then
Sheets("Resultados Individuales").Select
Range("n6:q6").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Principal").Select
Range("b6").Select
I have only been working with excel macros for 1 week so I am sorry if I write nonsense.
I now have a working macro but it is 1500 lines long because of the huge amount of possibilities of where to place the value of a copied cell.
Maybe you guys could be so kind to help me with the correct code.
It is (for me that is) simple:
Copy value from cells a1:d1
Paste it in sheet / cell
(this is the variable, in cell AL20 the sheet returns a cell ref depending of a selection in the sheet and there are 150 different possibilities) I need the macro to place the copied value en the cell specified in AL20 always checking first, what the value is.
Is that possible? Can you write the code? Will you help me please?
Thank you very much
This is the start of my macro as I found out to make it.
Sub PlaceSingleScores()
'
' Makro Place Singles Results
'
'Copy end destination from vlookup to next cell and paste value only
'
Sheets("Principal").Select
Range("AL19").Copy
Range("AL20").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
' Copy score one down value only
'
Range("Ao22:ar22").Copy
Range("ao23:ar23").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
' START actual macro
'
Range("$ao$23:$ar$23").Select
selection.Copy
If Range("$AL$19").Value = ("F6") Then
Sheets("Resultados Individuales").Select
Range("F6:i6").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Principal").Select
Range("b6").Select
ElseIf Range("$AL$19").Value = ("J6") Then
Sheets("Resultados Individuales").Select
Range("j6:m6").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Principal").Select
Range("b6").Select
ElseIf Range("$AL$19").Value = ("N6") Then
Sheets("Resultados Individuales").Select
Range("n6:q6").Select
selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Principal").Select
Range("b6").Select