Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Is there a way to change columns index with Excel 2007,or is it a

I have an Excel workbook that contains a lot of macros in it (programmed with
Excel 97). When I try to excute some code with Excel 2007 the column's index
seems to start at 0 instead of 1.

example: Target.Cells(1,9)... refers to J1 instead of Target.Cells(1,10)

But if I go on the worksheet enter someting in A1 and excute the code again:

Target.Cells(1,9)... refers to I1 and now Target.Cells(1,10) refers to J1.


Any ideas????

  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Is there a way to change columns index with Excel 2007,or is it a

Hi Clau -

It's likely not the column indexing that is causing the problem. It sounds
like some other code in your macros sets the value of Target to a range. The
property '.Cells(1,9)' refers to row1/col9 of that range and not to row1/col9
of the worksheet.

Initially, that range must start in column B resulting in Target.Cells(1,9)
referring to J1 (J is the 9th column in the range 'Target'). Furthermore,
the fact that simply entering a value in A1 changes Target.Cells(1,9) to
refer to I1 means that the variable 'Target' is set when a macro executes and
Target is dynamically set relative to entries on the worksheet somehow.

If you can find the statement(s) that set the variable 'Target', you could
monitor it's address under several scenarios with different worksheet
contents. Then you'll be in a better position to modify your code as needed.
Add the following statement after any statement that contains the variable
Target:

Msgbox Target.Address

If you're having trouble, post the code and we'll take a look.

---
Jay


"Clau" wrote:

I have an Excel workbook that contains a lot of macros in it (programmed with
Excel 97). When I try to excute some code with Excel 2007 the column's index
seems to start at 0 instead of 1.

example: Target.Cells(1,9)... refers to J1 instead of Target.Cells(1,10)

But if I go on the worksheet enter someting in A1 and excute the code again:

Target.Cells(1,9)... refers to I1 and now Target.Cells(1,10) refers to J1.


Any ideas????

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Is there a way to change columns index with Excel 2007,or is i

Thank you very much for your help, you gave me a good tip.

I was setting Target using Sheet(...).UsedRange, and the used range was
starting on column B.


"Jay" wrote:

Hi Clau -

It's likely not the column indexing that is causing the problem. It sounds
like some other code in your macros sets the value of Target to a range. The
property '.Cells(1,9)' refers to row1/col9 of that range and not to row1/col9
of the worksheet.

Initially, that range must start in column B resulting in Target.Cells(1,9)
referring to J1 (J is the 9th column in the range 'Target'). Furthermore,
the fact that simply entering a value in A1 changes Target.Cells(1,9) to
refer to I1 means that the variable 'Target' is set when a macro executes and
Target is dynamically set relative to entries on the worksheet somehow.

If you can find the statement(s) that set the variable 'Target', you could
monitor it's address under several scenarios with different worksheet
contents. Then you'll be in a better position to modify your code as needed.
Add the following statement after any statement that contains the variable
Target:

Msgbox Target.Address

If you're having trouble, post the code and we'll take a look.

---
Jay


"Clau" wrote:

I have an Excel workbook that contains a lot of macros in it (programmed with
Excel 97). When I try to excute some code with Excel 2007 the column's index
seems to start at 0 instead of 1.

example: Target.Cells(1,9)... refers to J1 instead of Target.Cells(1,10)

But if I go on the worksheet enter someting in A1 and excute the code again:

Target.Cells(1,9)... refers to I1 and now Target.Cells(1,10) refers to J1.


Any ideas????

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 2007 How to change width of stacked columns bowfin Charts and Charting in Excel 4 April 4th 23 10:55 AM
How do I change a long columns list to short ones in 2007 Excel? FitGurlFlea Excel Discussion (Misc queries) 1 February 19th 10 02:46 PM
Varied Results obtained using Index and Match in Excel 2003 and 2007 Krish Excel Worksheet Functions 0 October 28th 09 11:44 AM
Index and Match results vary in Excel 2003 and 2007 Krish Excel Discussion (Misc queries) 0 October 28th 09 12:32 AM
Excel 2007 extra columns - but transposing columns still not working! [email protected] Excel Programming 0 July 26th 06 02:58 PM


All times are GMT +1. The time now is 08:52 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"