ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Function to show all values (https://www.excelbanter.com/excel-discussion-misc-queries/183439-function-show-all-values.html)

AlejandroArias

Function to show all values
 
Hi, I have a sheet with the following structure

' A B C <-- Columns
/START/
1
2
3
4
5
6
7
8
9
10
11
/END/

Rows = 2 to n
Columns = 2 to n

I need a function to show each element in the sheet,
somthing like

CellStart = A1
CellEnd = A55...
CellTemp = CellStart

While CellTemp < CelEnd
if Worksheets(1).Range(CellTemp).Value < null then
MsgBox Worksheets(1).Range(CellTemp).Value
end if
move to the next value (maybe down, maybe left)
CellTemp = CellTemp + 1 row
Wend


Gary''s Student

Function to show all values
 
How about the following:

Sub alex()
Set r2 = Range("A1")
Set r1 = Range("A55")
Set rr = Range(r1, r2)
For Each r In rr
If Not IsEmpty(r.Value) Then
MsgBox (r.Value)
End If
Next
End Sub
--
Gary''s Student - gsnu2007g


"AlejandroArias" wrote:

Hi, I have a sheet with the following structure

' A B C <-- Columns
/START/
1
2
3
4
5
6
7
8
9
10
11
/END/

Rows = 2 to n
Columns = 2 to n

I need a function to show each element in the sheet,
somthing like

CellStart = A1
CellEnd = A55...
CellTemp = CellStart

While CellTemp < CelEnd
if Worksheets(1).Range(CellTemp).Value < null then
MsgBox Worksheets(1).Range(CellTemp).Value
end if
move to the next value (maybe down, maybe left)
CellTemp = CellTemp + 1 row
Wend



AlejandroArias

Function to show all values
 
Tkx Gary''s but I need show the others value too (2, 3, 4, 7, 8)

On 11 abr, 14:47, Gary''s Student
wrote:
How about the following:

Sub alex()
Set r2 = Range("A1")
Set r1 = Range("A55")
Set rr = Range(r1, r2)
For Each r In rr
If Not IsEmpty(r.Value) Then
MsgBox (r.Value)
End If
Next
End Sub
--
Gary''s Student - gsnu2007g

"AlejandroArias" wrote:
Hi, I have a sheet with the following structure


' A B C <-- Columns
/START/
1
2
3
4
5
6
7
8
9
10
11
/END/


Rows = 2 to n
Columns = 2 to n


I need a function to show each element in the sheet,
somthing like


CellStart = A1
CellEnd = A55...
CellTemp = CellStart


While CellTemp < CelEnd
if Worksheets(1).Range(CellTemp).Value < null then
MsgBox Worksheets(1).Range(CellTemp).Value
end if
move to the next value (maybe down, maybe left)
CellTemp = CellTemp + 1 row
Wend



AlejandroArias

Function to show all values
 
oK I modify the range and work... tkx

AlejandroArias

Function to show all values
 
If I use Range values is a little strong, because, maybe the rows or
colums grow not always have the same rows or columns on each execution


All times are GMT +1. The time now is 06:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com