Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Get Range object from Cell Row and Column No.

Try changing the last line to
Set GetJournalInsertRange = ActiveSheet.Cells(RowNumber,ColumnNumber)

OR try using this function...which do not loop

Function GetJournalInsertRange(ColumnHeader As String) As Range
Dim lngCol As Long, lngRow As Long
On Error Resume Next
lngCol = Range("JournalHdr").Find(ColumnHeader, _
LookIn:=xlValues, LookAt:=xlWhole).Column
If lngCol 0 Then
lngRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set GetJournalInsertRange = ActiveSheet.Cells(lngRow, lngCol)
End If

End Function

--
Jacob


"Simon" wrote:

Hi,

I'm using Excel 2003, I have a function which I want it to return a range
object which points to a cell, the cell is identified by the code which
determins which column number and row number make up the Cells RowIndex and
ColumnIndex attributes. For some reason I keep receiving an
application-defined or object-defined error, my code is below, any advice
would be appreciated:

Function GetJournalInsertRange(ColumnHeader As String) As Range
Dim ColumnNumber As Integer
Dim RowNumber As Integer
ColumnNumber = 0
For Each header In Range("JournalHdr")
If ColumnHeader = header.Text Then
ColumnNumber = header.Column
End If
Next
RowNumber = Range("A65536").End(xlUp).Offset(1, ColumnNumber - 1).Row
Set GetJournalInsertRange = ActiveSheet.Range(Cells(RowNumber,
ColumnNumber))

End Function

Thanks.
Simon

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
How do I pass a variable cell reference to a Range Object? Paula Excel Programming 2 November 2nd 08 02:17 AM
Help: Pivot Cache error using Range object containing cell with 255char keeena Excel Programming 0 January 11th 08 05:46 PM
Pivot Cache error using Range object containing cell with 255 char keeena[_2_] Excel Programming 0 December 14th 07 07:54 PM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM


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