LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default how do you use a variable a rage?

Here is my problem:

Here's the deal, when I export a file from a program to excel, some
things get screwed up that have to be fixed. This export is done
weekly, so it's important not to waste lots of time and so I figured
I could create a macro that would run and fix it all since week to week
the data is similar. Here is the issue, it all works great until a new
row is added and shifts everything down one and throws off the code in
VB since it is based on cell references (i.e. E3) and doesn't change
when the excel spreadsheet changes since the macro is a product of VB
code.


Here is an example of the code:



Range("D14:E14").Select
Selection.Cut Destination:=Range("E14:F14")
Range("D19:E19").Select
Selection.Cut Destination:=Range("E19:F19")
Range("D36:E36").Select
Selection.Cut Destination:=Range("E36:F36")




'This is basically moving move cells over one cell to the right.
(This has to be done about 50 times) What I would like to be able to do
is have the "14" be a variable so that I can just say the next one
is 'variable' = 'variable' + 5. and therefore down the line it
would update everything. If I had to add a row and the "14" is now
"15" the add 5 would make the next field "20" not "19" the
"36" a "37" and so on.

Is it possible to use a variable within the Range().select?
Or do you have any other ideas besides fixing the way it exports, which
I am also working on.

Thanks,

Dave S.

 
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
SUMIFS using a text rage Ziggy Excel Worksheet Functions 0 March 23rd 10 05:41 PM
SUMIFS using a text rage Ziggy Excel Worksheet Functions 0 March 23rd 10 05:41 PM
need help with look-up and time rage Noetic76 Excel Discussion (Misc queries) 4 February 24th 10 09:58 AM
Dynamic Rage - Drill down Jennifer Excel Worksheet Functions 3 December 18th 08 12:22 PM
Sum by date rage using multiple sheets Michael Excel Discussion (Misc queries) 3 March 24th 06 11:51 PM


All times are GMT +1. The time now is 01:34 AM.

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"