Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Creating a code for a macro

Hi, Can any one please help me with writing a code in visual basics?

What i am trying to do is this:
I want to create a button called 'close' in row 1(sheet 1) and when I click
this I want a marco to run which will delete the entire row that the button
is on and then paste that row into row 5 in worksheet 2. I want to repeat
this for the next row however, when the second row is pasted into worksheet 2
i want the second row to be pasted in row 5 and the first row move down to
row 6...

I hope this makes sense and would really appreciate any assistance from
anyone as i am not to familiar with writing up codes...THANK YOU in advance!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Creating a code for a macro

One way. Use ONLY one button and select the row first.

Sub movelastrowtoothersheet()
With Sheets("sheet2")
dlr = .Cells(Rows.Count, "a").End(xlUp).Row + 1
'MsgBox dlr
slr = ActiveCell.Row
'if you always want it to be the LAST row use this line instead
'slr = Cells(Rows.Count, "a").End(xlUp).Row
'MsgBox slr
Rows(slr).Copy .Cells(dlr, "a")
Rows(slr).Delete
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"engbe" wrote in message
...
Hi, Can any one please help me with writing a code in visual basics?

What i am trying to do is this:
I want to create a button called 'close' in row 1(sheet 1) and when I
click
this I want a marco to run which will delete the entire row that the
button
is on and then paste that row into row 5 in worksheet 2. I want to repeat
this for the next row however, when the second row is pasted into
worksheet 2
i want the second row to be pasted in row 5 and the first row move down to
row 6...

I hope this makes sense and would really appreciate any assistance from
anyone as i am not to familiar with writing up codes...THANK YOU in
advance!


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
Help! creating code for time to decimal calculations DW Excel Worksheet Functions 1 September 26th 07 06:39 PM
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
need help creating a Worksheet_Change code Cajun20th Excel Worksheet Functions 4 May 18th 06 09:12 AM
Code error in creating text files Greshter Excel Discussion (Misc queries) 3 January 15th 06 09:34 PM
Creating Macro or Code Help? Jeni Q Excel Worksheet Functions 2 September 13th 05 02:29 PM


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