LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Button to move row and delete old row

try going back to

activesheet.range("a4").select
ActiveCell.Insert Shift:=xlShiftDown
activesheet.paste

as for inserting to the bottom

ActiveSheet.UsedRange.Rows.Count

gives you the last row with data in it
adding one to that will give you the next row down
just select that and paste




"Stacie Fugate" wrote:

Okay, that worked great! But, one problem.. how do I get it to insert the
row instead of replacing what was currently in that row? Instead of
replacing the row that was there, I just need it to add the new row to that
list... either at the top or at the bottom. Thing of it is, the bottom row
number varies constantly, it could have 5 rows, it could have 60 rows... how
do I get it to know which row to go to?

Additionally, I have 3 different sections on my spreadsheet, how can I get
excel to recognize if a row is under Section 1, then move it to the next
available empty row in Section 1 on the Tracking Tab? If my cursor is on a
row in Section 2, then move this row to the next empty row in Section 2 on
the Tracking Tab.

Below is kinda an example of what my spreadsheet looks like. Both tabs look
identical, the only difference is the data under the column header...

WELL TYPE 1 INFORMATION
Smith #1 County ST 1/13/05
Jones #2 County ST 1/14/05

WELL TYPE 2 INFORMATION
Brown #3 County ST 1/16/05

WELL TYPE 3 INFORMATION
Haynes #6 County ST 1/17/05


"nippetee" wrote:

sometimes excel has no clue what sheet to do things coded even though it
seems clear to coder... :)

try put activesheet before that range line like this:

ActiveSheet.Range("A4").Select

This should work...

"Stacie Fugate" wrote:

I've created a button at the top of a spreadsheet that says "Move Row to
Tracking Tab". When this button is clicked, I want it to move the current
row (where their cursor is), to the Tracking Tab, and add it either at the
top of the spreadsheet (under the header row) or to the very bottom, while at
the same time, it deletes the old row from the first sheet entirely. The
first cell that contains data on the Tracking Tab is A4. Everything above
that is the header. (And just in case you need to know, the first tab is
titled "Western", and they are the only 2 tabs in the workbook) I've tried
the following code, but cant get it to work out right. It's giving me fits
with the line "Range("A4").Select", and I'm not really sure why.

Here is the code I used:

Private Sub MoveRow_Click()
ActiveCell.EntireRow.Copy
Worksheets("Tracking").Activate 'the other sheet
Range("A4").Select
ActiveCell.Insert Shift:=xlShiftDown
Worksheets("Western").Activate 'back to the original
ActiveCell.EntireRow.Delete Shift:=xlShiftUp
End Sub

 
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
Button macro to move/delete active row KevHardy Excel Discussion (Misc queries) 4 February 13th 10 11:59 AM
Any way to use toolbar button to delete cells and move cells "up"? Texas-Ron Excel Discussion (Misc queries) 2 April 7th 07 06:33 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM


All times are GMT +1. The time now is 05:08 PM.

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"