Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to Select and Cut the Next Non Empty Cell in a Column 2

Status
Not open for further replies.

Forrest77

Technical User
Apr 5, 2006
31
0
0
US
To begin Thank You for any and all help. I am very weak at this.
I want to put some code into a command button that when clicked will go to a Column on my excel sheet, select and cut the next available cell with data (skipping over the empty cells) and paste it into a different cell location on the Excell sheet. The plan is that ever time the command button is clicked, it will cut and paste the next cell down because I will be removing Data and creating empty cells with the cut rather than copy command. Hope this makes sense.
Thanks again for your help
Todd
 
And what have you tried so far ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Here's a starting point:

Use
Code:
Range("A" & ActiveSheet.Rows.Count).End(xlUp).Cut
to find the last row of populated data in a given row. To change the column, just change A to another column heading.


[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
Another Higgins,
Thank You very very much for your answer. It looks perfect. I won't get a chance to try it until Monday but will let you know. Thanks again
Forrest
 
AnotherHiggins,
I see that the code cut the first available full cell at the bottom of the column and works its way up. How do you change that to cut the first available full cell from the top and work ones way down. I am then trying to paste that into a different cell and by the following code but I get a debug. Not sure what is wrong here:

Sheet1.Activate
Range("Z" & ActiveSheet.Rows.Count).End(xlUp).Cut
Sheet1.Range("y1:y1").PasteSpecial
The paste part is not working...
Thanks,
Forrest
 



You are CUTTING a range. Don't believe that you can do it all in one operation.
Code:
    Dim rng As Range
    Set rng = Sheet1.Range("Z" & Sheet1.Rows.Count).End(xlUp)
    rng.Copy
    Sheet1.Range("y1").PasteSpecial xlPasteAll
    rng.Delete xlUp


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thank You Skipvought,
That makes sense. I had also worked on just copying and then deleting the cell which would accoumplish the same thing. Do you know how to code for the cell to be copied to be the first cell of the column that has data from the top down rather than from the bottom up. The code I have works from the bottom up and I can't figure how to change this
Range("A" & ActiveSheet.Rows.Count).End(xlUp).copy
to make it start at the top of the column rather than the bottom.
Thanks for your help again
Todd
 
Try this:
Range("A:A").Find("*").Copy

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH,
Well you got it and it works perfectly. It skips the first cell in the column but after that it works fine. If I leave the first cell blank, it will work just like it should. Your code looks easy and I was trying to make it too hard. I need a good book on this stuff.
Thanks again
Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top