Thread: Code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Code

Hi Alex,

Try:

Private Sub CommandButton1_Click()
Dim rng As Range

If Application.CountA(Me.Range("A10:D10")) = 0 Then
Set rng = Me.Range("A10")
Else
Set rng = Cells(Rows.Count, "A").End(xlUp)(2)
End If

Me.Range("B1:B4").Copy
rng.PasteSpecial Paste:=xlAll, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=True

End Sub


---
Regards,
Norman



"Alex" wrote in message
...
Dear ALL

I have the following question:

I placed the button on the excel sheet and assign a macro which cuts the
cells' values from range b1:b4 and pastes them into range a10:d10
everything
is ok and works perfectly, but how can I do so that when I press the
button
again the new values which i type in range b1:b4 placed in a11:d11 ? and
so
on, is it possible?

Please help me with this
Thank you in advance

My Code:
Private Sub CommandButton1_Click()
If Range("A10") = "" Then

Range("B1").Select
Selection.Cut
Range("A10").Select
ActiveSheet.Paste
Range("B2").Select
Selection.Cut
Range("B10").Select
ActiveSheet.Paste
Range("B3").Select
Selection.Cut
Range("C10").Select
ActiveSheet.Paste
Range("B4").Select
Selection.Cut
Range("D10").Select
ActiveSheet.Paste
Else
Range("B1").Select
Selection.Cut
Range("A11").Select
ActiveSheet.Paste
Range("B2").Select
Selection.Cut
Range("B11").Select
ActiveSheet.Paste
Range("B3").Select
Selection.Cut
Range("C11").Select
ActiveSheet.Paste
Range("B4").Select
Selection.Cut
Range("D11").Select
ActiveSheet.Paste

End If

End Sub

what should I do to continue the code for next ranges?