View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
AKphidelt AKphidelt is offline
external usenet poster
 
Posts: 461
Default Macro to move one cell down

This is making absolutely no sense. What you are saying is you want the last
cell that was inputed... the line

Range("A65536").End(xlUp).Select

will choose only one cell and will choose the last cell in column A that has
data in it. So regardless of how many extra lines you put in, it will choose
the last cell. Tell you what, go down to Cell A65536 and press CTRL + Up
Arrow. That's all that code is doing.

I'm completely lost in what you are trying to do with having a user click a
command button and have it go from A1 to A2. Do you want it to do that every
time? If so you are going to have to figure out some way to create a variable
that knows when you want to start over or a static variable that remembers
what the last row you copied was.

"tjb" wrote:

I'm not selecting a range, just the contents of the cell selected after
moving down one until blank.

"akphidelt" wrote:

Oh wow, thats completely different then I imagined. So is there criteria that
has to be met to determine what workbook to go to or are you just copying all
the data from A1:A356 to another workbook?

To get a dynamic range you use

Range(Range("A1"),Range("A1").End(xlDown)).Select

This will select the entire range as long as it has data in column A
regardless of the amount of rows.

"tjb" wrote:

Still no go. To be clear, I have data in cells A1:A356. When the user
clicks the command button, I want the macro to copy cell A1 and insert in the
appropriate workbook. When the user clicks the command button again, I want
the macro to copy cell A2 and so on until it sees no data in cell A357.
Thanks for working on this for me!

"akphidelt" wrote:

Alright, I should have looked at the code harder. I was getting the first
blank cell available when what you want is the last cell that was updated. So
just use

Range("A65536").End(xlUp).Select

And it should work.

"tjb" wrote:

That didn't quite work and I'm not sure I follow what you were trying to do
with the code.

"akphidelt" wrote:

Try

Windows("Extract.xls").Activate
Range("A65536").End(xlUp).Offset(1,0).Select
Selection.Copy
Windows("PascoTOC.xls").Activate
Range("E8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

"tjb" wrote:

Instead of "Range("A4").Select" from the code below I want the code to just
go one cell down until it finds a blank cell. This is a macro that would be
run one at a time and not on a loop. For example, the user will click a
command button, the code would run once (unless it finds an empty cell) and
then end until the user clicks the command button again. Obviously this is
very possible but I'm at a loss for the code. Thanks all!

Windows("Extract.xls").Activate
Range("A4").Select
Selection.Copy
Windows("PascoTOC.xls").Activate
Range("E8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False