• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Give value to msgbox from a value of activecell this need to be in a loop

vengal1987

New Member
Hi Team,


I am working on macro, where i need a msg box to be populated with a value from an activecell.

and the activecell will be change everytime.


for e.g.

I have some numbers say 1-10 and i need that numbers to populate in my msg box from

1-10 each number.


As of now i have below msg box VBA code.

[pre]
Code:
Dim a As Integer
Range("A1").Select

a = 2
While (Range("A" & a).Value <> "")
MsgBox (ActiveCell.Offset(0, 4).Value)
Wend
a = a + 1
[/pre]
but the above code giving me the value only for one cell, & i want it to work till complete my loop.


Kindly help.
 
Hi ,


Certainly uploading your file will be helpful , but in the meantime , can you try the following ?

[pre]
Code:
Dim a As Integer
Range("A1").Select

a = 2
While (Range("A" & a).Value <> "")
MsgBox (ActiveCell.Offset(0, 4).Value)
a = a + 1
Wend
[/pre]
The point is that the While ... Wend construct forms a loop ; within the loop you need to increment the counter , so that each time through the loop the incremented number will be used.


Narayan
 
Hi jeffreyweir/NARAYANK991


I have loaded worksheet on below link, please let me know if you need any other details.


http://speedy.sh/MTUZA/Msg-box-file.xlsx
 
Hi, vengal1987!

Regarding your column G data, what do you mean by "This numbers should be active with msg box", that each number of range G2:G26 should be displayed using MsgBox for... which active cells?

Please elaborate and reformulate in other words. Thank you.

Regards!
 
Back
Top