Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Using Debug.Print with Range Variable with more than one cell

I have a range variable. I want to print its value to the Immediate Window
upon selection of it.

Currently I use this to do so:
var1 = Target
Debug.Print var1

However this fails if the range is greater than one cell. How can I modify
this to print all values in the selection?

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Using Debug.Print with Range Variable with more than one cell

var1 = Range("A1:A10")
For Each strval In var1
Debug.Print strval
Next

--
If this post helps click Yes
---------------
Jacob Skaria


"ExcelMonkey" wrote:

I have a range variable. I want to print its value to the Immediate Window
upon selection of it.

Currently I use this to do so:
var1 = Target
Debug.Print var1

However this fails if the range is greater than one cell. How can I modify
this to print all values in the selection?

Thanks

EM

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Using Debug.Print with Range Variable with more than one cell

This way your range can be dynamic

Sub way()
Dim yourVariable As Range
Dim i As Long
Set yourVariable = Selection
For i = 1 To Selection.Cells.Count
Debug.Print yourVariable(i)
Next
End Sub

"Jacob Skaria" wrote:

var1 = Range("A1:A10")
For Each strval In var1
Debug.Print strval
Next

--
If this post helps click Yes
---------------
Jacob Skaria


"ExcelMonkey" wrote:

I have a range variable. I want to print its value to the Immediate Window
upon selection of it.

Currently I use this to do so:
var1 = Target
Debug.Print var1

However this fails if the range is greater than one cell. How can I modify
this to print all values in the selection?

Thanks

EM

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Using Debug.Print with Range Variable with more than one cell

Thanks

"Jacob Skaria" wrote:

var1 = Range("A1:A10")
For Each strval In var1
Debug.Print strval
Next

--
If this post helps click Yes
---------------
Jacob Skaria


"ExcelMonkey" wrote:

I have a range variable. I want to print its value to the Immediate Window
upon selection of it.

Currently I use this to do so:
var1 = Target
Debug.Print var1

However this fails if the range is greater than one cell. How can I modify
this to print all values in the selection?

Thanks

EM

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
Set print area on variable range Tom Excel Programming 4 March 28th 07 03:52 PM
Variable Print Range Sami82[_25_] Excel Programming 5 February 8th 06 04:38 AM
debug.print range "full" address Patti[_2_] Excel Programming 5 July 6th 05 09:27 PM
debug error: object variable not set Michael A Excel Programming 2 March 12th 05 12:23 AM
Setting up a variable print range Gary[_5_] Excel Programming 5 July 31st 03 04:32 AM


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