Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default insert row and range changes problem?

I'm quite new to Excel programming. I have a worksheet with change event
code calling a sub that builds a color and inventory matrix to the right of
a part number in column 1. The data is coming from XML files using MSXMLDOM
in code. One entry in column 1 will fill several columns and rows which is
all working. I now want to enhance this to be able to paste in several part
numbers into column 1 at once. How do I keep track of the cells with the
part numbers? The change event has a range parameter but as I insert rows
with my code to build the matrix between the numbers pasted in the range
keeps changing.

thanks
LJB


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default insert row and range changes problem?

You can get the last row easily with this code

cLastRow = Cells(Rows.Count,"A").End(xlUp).Row

and use this in your tests.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ljb" <. wrote in message ...
I'm quite new to Excel programming. I have a worksheet with change event
code calling a sub that builds a color and inventory matrix to the right

of
a part number in column 1. The data is coming from XML files using

MSXMLDOM
in code. One entry in column 1 will fill several columns and rows which is
all working. I now want to enhance this to be able to paste in several

part
numbers into column 1 at once. How do I keep track of the cells with the
part numbers? The change event has a range parameter but as I insert rows
with my code to build the matrix between the numbers pasted in the range
keeps changing.

thanks
LJB




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default insert row and range changes problem?


Hi LJB,

Bob's code will work well to find the last row in the worksheet. Thanks
Bob!

Since your new to Excel automation programming I thought it appropriate to
point out a couple of common potential traps that may make your experience
go smoother.

You didn't say if you were using VB or VBA but it looks like VB. Be careful
with unqualified expressions. Make sure all of your method and property
references are qualified with an object. For example,

cLastRow = Cells(Rows.Count,"A").End(xlUp).Row

In this example Cells is qualified. It is referencing an uncoded WorkSheet
object. This can work in VBA, but can fail consistently or randomly in
compiled VB. The correct reference would be

Dim oApp as new Excel.Application

cLastRow = oApp.ActiveSheet.Cells ...

Also, many of my support cases involve problems with Excel not shutting
down properly. You can ensure Excel shuts down properly by always calling
the Quit method using late binding. Don't rely on simply setting the app
variable to nothing. Here's an example:

Dim oXLApp as new Excel.Application
Dim oObj as Object

' Do your automation

' Shut down Excel
set oObj = oXLApp
oObj.Quit
set oObj = nothing
set OXLApp = nothing

Hope this information is helpful.

Thanks,

Jim

Jim Vita
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

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
Insert Object Problem Raj Excel Discussion (Misc queries) 1 April 20th 10 05:18 PM
Insert Rows Problem comotoman Excel Discussion (Misc queries) 3 October 7th 05 05:20 PM
insert row problem WYN Excel Discussion (Misc queries) 3 June 30th 05 05:46 AM
Insert...Name Range childofthe1980s Excel Discussion (Misc queries) 1 May 24th 05 03:52 PM
Insert\Name\Apply.... problem David Excel Worksheet Functions 6 February 25th 05 12:49 PM


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