Vb to Excel range issues

  • Thread starter Thread starter cmdolcet69
  • Start date Start date
C

cmdolcet69

Im havening an issue with my range function in vb.net

I have the following: OResizeRange = ows.range ("C33", "IR46")

Where the problem lies is that its not always ending at IR46 it
sometimes can be ending larger or smaller how can i factor the range
based off the size of collected data in my vb program
 
You can use (String) variables and make up the ending range in a dynamic way.

In this notation, as long as it is the name of a column followed by a row
number.

Can you give me an example...
 
How do you determine the topleft corner and the bottom right corner?

If it always starts in C33 and you can pick out a column and row to determine
where it should stop, then maybe...

Dim LastRow as long
dim LastCol as long
dim oResizeRange as range

with ows
lastrow = .cells(.rows.count,"A").end(xlup).row
lastcol = .cells(32,.columns.count).end(xltoleft).column
set oresizerange = .range("c33",.cells(lastrow,lastcol))
end with

In this case, I used column A to determine the last row and row 32 to determine
the last column.
 
For instance

OResizeRange = ows.range ("C33", Range("IR" & rows.count).End(xlUp))

Here the range extends until the last cell used in column IR.

Many other variations are possible as well.
 
Can this work? OResizeRange = ows.range ("C33", "IR") but it may
sometimes be "IR" or even "C39" how can i see what the last row it
writes to and then calculate my range based off of that?
 
Back
Top