finalcolumn?

xtscars

New Member
Joined
Apr 11, 2011
Messages
17
I'm trying to paste something in the final column +1. right now I have: finalcolumn=Range("XFD1").End(xlToLeft).Column

so if I understand it, I have just defined what "finalcolumn" means, right? So now that it's defined, how do I actually use it? Range("finalcolumn")? Super confused. Thanks!
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,456
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Board!

You have just stored the column reference number.
So you could use:
Cells(1,finalcolumn).Offset(0,1).Select
to select the first blank column after the last populated column in row 1.
(note the format is Cells(row, column) and Offset(row, column))
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Hi and welcome to the board!!!
There are several ways to do this depending on you need. The way you are doing this, you are getting the Column Number of the Final Column. So to get the cell in Row 1 for the next column, you can use
Code:
Cells(1,finalcolumn+1)
As I said, until we know more about your needs, we can only guess the best way

lenze
 

xtscars

New Member
Joined
Apr 11, 2011
Messages
17
you guys rock! I have recorded a macro but it's sloppy and with all the offsets, whenever there is a change, it's thrown off, so I'm trying to use variables. I'm new to all this, though, so I'm struggling. I'll be back with more questions. thanks for the help!
 

xtscars

New Member
Joined
Apr 11, 2011
Messages
17

ADVERTISEMENT

what is the best way to copy and paste in relation to the final row or column? For example I want to copy the top row final column, and move one column over to the right, and paste it there. This is what I'm playing with, and failing:

Cells(1,finalcolumn).select
Range("").Copy destination: range (""+1)

Any thoughts?
 

xtscars

New Member
Joined
Apr 11, 2011
Messages
17
is there a neater way to do this?

cells(1,finalcolumn).select
selection.copy
cells(a,finalcolumn+1).select
selection.paste

I think that works, but there is a better way, right?
 

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,196

ADVERTISEMENT

Code:
cells(1,finalcolumn).copy cells(a,finalcolumn+1)
 

xtscars

New Member
Joined
Apr 11, 2011
Messages
17
it worked! I put "1" instead of "a" in your equation, and it worked. What I don't understand is where in your code it directs excel to paste it? All I see is a command to copy, how does it know to paste? Thanks!
 

Weaver

Well-known Member
Joined
Sep 10, 2008
Messages
5,196
the destination is an 'argument' of the copy command

It should look like

Code:
cells(a,finalcolumn).copy destination:=cells(a,finalcolumn+1)
but since it's the first argument, it doesn't need to be specific.
 

xtscars

New Member
Joined
Apr 11, 2011
Messages
17
thank you! If you don't mind, would you help me figure this one out, too? I'm trying to copy the entire final column.

I'm trying something like this: range(1,finalcolumn:finalrow,finalcolumn).copy

but that's not flying.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,955
Messages
5,525,882
Members
409,669
Latest member
JDCupps

This Week's Hot Topics

Top