![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 05:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com