Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Dim As Range Object

Hi,

I am writing a macro to call another sub. One of the argument that I pass to
the other sub is a range object. I just found that if the range has content,
value of the variable will become to the value of the range. In my case, if
the range("A4") store a string "ABC", then the variable PasteAt="ABC". This
will result in error when the other sub is going to paste data of recordset
at a specific range. Can you tell me how to solve this problem? Your help
will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String, PasteAt As
Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
....
....
Call GetData(Server, Database, SQLcommand, PasteAt)
....
....
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As Range)
....
....
End Sub


Billy



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default Dim As Range Object

What value should your range Object store if NOT the Cell you Set it to?



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi,

I am writing a macro to call another sub. One of the argument that I pass
to the other sub is a range object. I just found that if the range has
content, value of the variable will become to the value of the range. In
my case, if the range("A4") store a string "ABC", then the variable
PasteAt="ABC". This will result in error when the other sub is going to
paste data of recordset at a specific range. Can you tell me how to solve
this problem? Your help will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String, PasteAt As
Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
...
...
Call GetData(Server, Database, SQLcommand, PasteAt)
...
...
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As Range)
...
...
End Sub


Billy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Dim As Range Object

Hi Dave,
Thanks for your prompt response. In my case, I want to pass the "location"
to the other sub. The "location" means where I would like to paste the
recordset. If the range("A4") is empty, the macro run perfectly. (By the
way, if I type ?PasteAt in immediate windows, it doesn't show anything. Is
that normal?). Should I have to clear the content of range("A4") before I
set PasteAT?

Billy

"ozgrid.com" wrote in message
...
What value should your range Object store if NOT the Cell you Set it to?



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi,

I am writing a macro to call another sub. One of the argument that I pass
to the other sub is a range object. I just found that if the range has
content, value of the variable will become to the value of the range. In
my case, if the range("A4") store a string "ABC", then the variable
PasteAt="ABC". This will result in error when the other sub is going to
paste data of recordset at a specific range. Can you tell me how to solve
this problem? Your help will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String, PasteAt
As Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
...
...
Call GetData(Server, Database, SQLcommand, PasteAt)
...
...
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As Range)
...
...
End Sub


Billy






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default Dim As Range Object

Why not clear the Range before passing the Range Object?

Or use;
Set PasteAt =Cells(Rows.Count,"A").End(XlUp)(2,1)



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi Dave,
Thanks for your prompt response. In my case, I want to pass the "location"
to the other sub. The "location" means where I would like to paste the
recordset. If the range("A4") is empty, the macro run perfectly. (By the
way, if I type ?PasteAt in immediate windows, it doesn't show anything. Is
that normal?). Should I have to clear the content of range("A4") before I
set PasteAT?

Billy

"ozgrid.com" wrote in message
...
What value should your range Object store if NOT the Cell you Set it to?



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi,

I am writing a macro to call another sub. One of the argument that I
pass to the other sub is a range object. I just found that if the range
has content, value of the variable will become to the value of the
range. In my case, if the range("A4") store a string "ABC", then the
variable PasteAt="ABC". This will result in error when the other sub is
going to paste data of recordset at a specific range. Can you tell me
how to solve this problem? Your help will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String, PasteAt
As Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
...
...
Call GetData(Server, Database, SQLcommand, PasteAt)
...
...
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As
Range)
...
...
End Sub


Billy







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Dim As Range Object

Hi Dave,
In my case, yes, I can clear the range first. But for arguement sake, if I
need to maintain the value but need to pass the range object, what should I
do?

(the second option you offer is going to the last cell of the sheet. am I
correct?)

Billy

"ozgrid.com" wrote in message
...
Why not clear the Range before passing the Range Object?

Or use;
Set PasteAt =Cells(Rows.Count,"A").End(XlUp)(2,1)



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi Dave,
Thanks for your prompt response. In my case, I want to pass the
"location" to the other sub. The "location" means where I would like to
paste the recordset. If the range("A4") is empty, the macro run
perfectly. (By the way, if I type ?PasteAt in immediate windows, it
doesn't show anything. Is that normal?). Should I have to clear the
content of range("A4") before I set PasteAT?

Billy

"ozgrid.com" wrote in message
...
What value should your range Object store if NOT the Cell you Set it to?



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi,

I am writing a macro to call another sub. One of the argument that I
pass to the other sub is a range object. I just found that if the range
has content, value of the variable will become to the value of the
range. In my case, if the range("A4") store a string "ABC", then the
variable PasteAt="ABC". This will result in error when the other sub is
going to paste data of recordset at a specific range. Can you tell me
how to solve this problem? Your help will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String, PasteAt
As Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
...
...
Call GetData(Server, Database, SQLcommand, PasteAt)
...
...
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As
Range)
...
...
End Sub


Billy












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 464
Default Dim As Range Object

IF PasteAt<VbNullString Then Range("A4").Cut Cells(Rows.Count,
Columns.Count)
'YOUR CODE



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi Dave,
In my case, yes, I can clear the range first. But for arguement sake, if I
need to maintain the value but need to pass the range object, what should
I do?

(the second option you offer is going to the last cell of the sheet. am I
correct?)

Billy

"ozgrid.com" wrote in message
...
Why not clear the Range before passing the Range Object?

Or use;
Set PasteAt =Cells(Rows.Count,"A").End(XlUp)(2,1)



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi Dave,
Thanks for your prompt response. In my case, I want to pass the
"location" to the other sub. The "location" means where I would like to
paste the recordset. If the range("A4") is empty, the macro run
perfectly. (By the way, if I type ?PasteAt in immediate windows, it
doesn't show anything. Is that normal?). Should I have to clear the
content of range("A4") before I set PasteAT?

Billy

"ozgrid.com" wrote in message
...
What value should your range Object store if NOT the Cell you Set it
to?



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi,

I am writing a macro to call another sub. One of the argument that I
pass to the other sub is a range object. I just found that if the
range has content, value of the variable will become to the value of
the range. In my case, if the range("A4") store a string "ABC", then
the variable PasteAt="ABC". This will result in error when the other
sub is going to paste data of recordset at a specific range. Can you
tell me how to solve this problem? Your help will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String,
PasteAt As Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
...
...
Call GetData(Server, Database, SQLcommand, PasteAt)
...
...
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As
Range)
...
...
End Sub


Billy











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Dim As Range Object

Dave,
Thanks.
Billy
"ozgrid.com" wrote in message
...
IF PasteAt<VbNullString Then Range("A4").Cut Cells(Rows.Count,
Columns.Count)
'YOUR CODE



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi Dave,
In my case, yes, I can clear the range first. But for arguement sake, if
I need to maintain the value but need to pass the range object, what
should I do?

(the second option you offer is going to the last cell of the sheet. am I
correct?)

Billy

"ozgrid.com" wrote in message
...
Why not clear the Range before passing the Range Object?

Or use;
Set PasteAt =Cells(Rows.Count,"A").End(XlUp)(2,1)



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi Dave,
Thanks for your prompt response. In my case, I want to pass the
"location" to the other sub. The "location" means where I would like to
paste the recordset. If the range("A4") is empty, the macro run
perfectly. (By the way, if I type ?PasteAt in immediate windows, it
doesn't show anything. Is that normal?). Should I have to clear the
content of range("A4") before I set PasteAT?

Billy

"ozgrid.com" wrote in message
...
What value should your range Object store if NOT the Cell you Set it
to?



--
Regards
Dave Hawley
www.ozgrid.com
"Billy Leung" wrote in message
...
Hi,

I am writing a macro to call another sub. One of the argument that I
pass to the other sub is a range object. I just found that if the
range has content, value of the variable will become to the value of
the range. In my case, if the range("A4") store a string "ABC", then
the variable PasteAt="ABC". This will result in error when the other
sub is going to paste data of recordset at a specific range. Can you
tell me how to solve this problem? Your help will be appreciated.

The following is my coding.


Sub main()
Dim Server As String, Database As String, SQLcommand As String,
PasteAt As Range
Server = "SBS-2003"
Database = "Data-03"
Set PasteAt = Range("A4")
...
...
Call GetData(Server, Database, SQLcommand, PasteAt)
...
...
End Sub

Sub GetData(Svr As String, Db As String, SqlCmd As String, Pste As
Range)
...
...
End Sub


Billy














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
Range object evaluates to Range.value, or Range object [email protected] Excel Programming 12 June 4th 09 07:28 PM
returning pivottable object from a range object Grant Excel Programming 2 September 27th 04 02:22 AM
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
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


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