Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
243 views
in Technique[技术] by (71.8m points)

excel - How do I make a list in a MsgBox (VBA)?

Using VBA, I'm making a sub that should, in some instances, output maybe hundreds of strings. Can I make a long MsgBox where all of those strings are occupying a different paragraph each? In my workbook, the worksheets have tables with the code of a product in the first column and the stock in the eighth (last), I have made the function AverageStock that returns the average stock of a certain product code in a worksheet.

Sub test()

Dim product_code as String
Dim LRow as Integer
Dim k as Integer

LRow = Range("A3").End(xlDown).Row
product_code = InputBox("Product Code")

For k = 3 To LRow
        If Cells(k, 8) > AverageStock(product_code) Then

I only have this till now, any help/suggestions?

question from:https://stackoverflow.com/questions/65872843/how-do-i-make-a-list-in-a-msgbox-vba

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

MsgBox will only contain text and a title: https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/msgbox-function

The option you have is to create a custom UserForm.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...