Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
JDM JDM is offline
external usenet poster
 
Posts: 7
Default Changing Column Reference in Macros?

I want to write a macro that will move to the next column each time I run it.
Below is what I have from a recording. I need to change the "AC:AC" to
"AD:AD" next time I run this macro, same for the AD below that. I can create
a table in my worksheets that will always have the new column to point to,
but I don't know how to reference it in my macro.

ActiveWindow.SmallScroll Down:=-16
Sheets(Array("Deposits", "Rates")).Select
Sheets("Deposits").Activate
Columns("AC:AC").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AD:AD").Select
Selection.Insert Shift:=xlToRight
Columns("AC:AC").Select
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Changing Column Reference in Macros?

hi
you could use a variable in a cell on the sheet. just type in the next
column. then add this to your code.

dim v as string
v = range("A1").value
colunms(v).select

regards
FSt1



"JDM" wrote:

I want to write a macro that will move to the next column each time I run it.
Below is what I have from a recording. I need to change the "AC:AC" to
"AD:AD" next time I run this macro, same for the AD below that. I can create
a table in my worksheets that will always have the new column to point to,
but I don't know how to reference it in my macro.

ActiveWindow.SmallScroll Down:=-16
Sheets(Array("Deposits", "Rates")).Select
Sheets("Deposits").Activate
Columns("AC:AC").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AD:AD").Select
Selection.Insert Shift:=xlToRight
Columns("AC:AC").Select

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Changing Column Reference in Macros?

hi again
forgot to mention. you don't need to reverence the column as AC:AC. you can
use just AC. excel will understand.

regards
FSt1

"JDM" wrote:

I want to write a macro that will move to the next column each time I run it.
Below is what I have from a recording. I need to change the "AC:AC" to
"AD:AD" next time I run this macro, same for the AD below that. I can create
a table in my worksheets that will always have the new column to point to,
but I don't know how to reference it in my macro.

ActiveWindow.SmallScroll Down:=-16
Sheets(Array("Deposits", "Rates")).Select
Sheets("Deposits").Activate
Columns("AC:AC").Select
Application.CutCopyMode = False
Selection.Copy
Columns("AD:AD").Select
Selection.Insert Shift:=xlToRight
Columns("AC:AC").Select

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
Excel - changing column reference based on value of other column Dharmesh Patel Excel Discussion (Misc queries) 4 October 12th 09 02:41 PM
MS Excel - changing reference column value based on another column Dharmesh Patel[_2_] Excel Discussion (Misc queries) 2 October 12th 09 01:19 PM
Excel - changing column reference based on value of other column Dharmesh Patel Excel Discussion (Misc queries) 2 October 12th 09 01:18 PM
Pasting Forumulas without changing row and/or column reference Pat Excel Discussion (Misc queries) 3 August 13th 08 10:40 PM
Stop cell reference in formula changing when insert column? Bobbie Weeks (Ms) Excel Discussion (Misc queries) 1 May 30th 08 06:20 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"