Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Cursor Movement vs. Range Reference

I am opening an XML file in Excel 2002 and performing some data
manipulation (via macros) in Excel before linking the newly saved Excel
file to Microsoft Access 2000.

Once the XML file is opened in Excel, it displays all table headings in
numerous columns on the first row. For example, a table heading could
be: "/PROJECT/AREAS/TEXTEXEC1". All data for this heading begins in
this column on the second row and so forth. While all XML files that I
use will have the tableheadings that I need, there are certain XML
files that will not list tableheadings is there is no data associated
with that particular project file. As a result,
"/PROJECT/AREAS/TEXTEXEC1" could be located in column Z for one file
and column AB in another. This is where I have a problem. The macros
written by the Record Macro function uses column (range) references
when I actually need it to refer to cursor positions relative to
"/PROJECT/AREAS/TEXTEXEC1". Since the column where this dataset is
located may vary between Excel files, I need to build my references to
cursor positions in relation to the cell that /PROJECT/AREAS/TEXTEXEC1
is located. In addition, I am trying to Text to Columns that data in
that column and I don't know how via Macros to anchor the cursor and
highlight a range of say 500 rows.

The following is my current macro with range references that I need to
convert to reference off my tableheading:

Cells.Find(What:="/PROJECT/AREAS/FOLDER/AREA/STEP/TEXTEXEC2", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
Range("AO1").Select
Selection.EntireColumn.Insert
Range("AN2:AN578").Select
Selection.TextToColumns Destination:=Range("AN2"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote,
ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False,
Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)),
TrailingMinusNumbers:=True
Range("AN1").Select
Selection.AutoFill Destination:=Range("AN1:AO1"), Type:=xlFillDefault
Range("AN1:AO1").Select

******
Any Help would be appreciated!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Cursor Movement vs. Range Reference

Jeff

Use a Range variable in your Find statement

Dim rFound as Range

'rFound will be the cell that contains the results of the Find
Set rFound = ActiveSheet.Cells.Find(What:=....)

If Not rFound Is Nothing Then 'it found the cell

'reference cells relative to rFound
rFound.Offset(1,1).Value = 1 'set the value one row down
'and one to the right to
1

'Resize rFound
rFound.Resize(500) 'resize rFound from one row to 500

End If

Generally, you don't want to select a range and then do something to it.
Just refer to the range and do the action. Here are some more specific
examples

To insert a column to the right of rFound

rFound.Offset(0,1).EntireColumn.Insert

To TTC all the data in the same column as rFound

rFound.Parent.Range(rFound, rFound.End(xlDown)).TextToColumns...

So use Find to establish rFound, then use End, Offset, and Resize to
reference the ranges you need. Post back if you have specific questions
when you get into it.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com


Jeff wrote:
I am opening an XML file in Excel 2002 and performing some data
manipulation (via macros) in Excel before linking the newly saved
Excel file to Microsoft Access 2000.

Once the XML file is opened in Excel, it displays all table headings
in numerous columns on the first row. For example, a table heading
could be: "/PROJECT/AREAS/TEXTEXEC1". All data for this heading
begins in this column on the second row and so forth. While all XML
files that I use will have the tableheadings that I need, there are
certain XML files that will not list tableheadings is there is no
data associated with that particular project file. As a result,
"/PROJECT/AREAS/TEXTEXEC1" could be located in column Z for one file
and column AB in another. This is where I have a problem. The macros
written by the Record Macro function uses column (range) references
when I actually need it to refer to cursor positions relative to
"/PROJECT/AREAS/TEXTEXEC1". Since the column where this dataset is
located may vary between Excel files, I need to build my references to
cursor positions in relation to the cell that /PROJECT/AREAS/TEXTEXEC1
is located. In addition, I am trying to Text to Columns that data in
that column and I don't know how via Macros to anchor the cursor and
highlight a range of say 500 rows.

The following is my current macro with range references that I need to
convert to reference off my tableheading:

Cells.Find(What:="/PROJECT/AREAS/FOLDER/AREA/STEP/TEXTEXEC2", After:=
_ ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart,
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
Range("AO1").Select
Selection.EntireColumn.Insert
Range("AN2:AN578").Select
Selection.TextToColumns Destination:=Range("AN2"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote,
ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False,
Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)),
TrailingMinusNumbers:=True
Range("AN1").Select
Selection.AutoFill Destination:=Range("AN1:AO1"), Type:=xlFillDefault
Range("AN1:AO1").Select

******
Any Help would be appreciated!!!



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
Movement of the cursor tran1728 Excel Discussion (Misc queries) 4 May 8th 10 05:28 AM
CURSOR MOVEMENT Aligahk06 Excel Discussion (Misc queries) 3 September 9th 09 04:55 PM
how can I limit cursor movement within specified range in excel? slk0217 Excel Discussion (Misc queries) 2 January 5th 08 06:03 AM
how to confine the range of movement of cursor starwil[_2_] Excel Programming 2 May 27th 04 10:16 AM
how to confine the range of movement of cursor starwil[_2_] Excel Programming 6 May 24th 04 03:38 PM


All times are GMT +1. The time now is 03:33 AM.

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"