Dynamic msgbox base on blank cell

virakbot

New Member
Joined
Aug 13, 2018
Messages
13
I've designed excel file for showing pending task. I want msgbox dimension to fit with only rows which have blank cell on column "F", but msgbox dimension is fit with 100 as i in my code

Sub Pending()
Dim r As Long
Dim msg As String, i As Long, a As Variant
msg = ""
For i = 2 To 100
For Each a In Array("F")
If Range("E" & i) <> "" And Cells(i, a).Value = "" Then
msg = msg & Range("D" & i) & " " & Range("E" & i) & Cells(i, a).Value & vbTab
End If
Next a
msg = msg & vbCrLf
Next i

MsgBox msg

End Sub
filter.jpg
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Code:
For Each a In Array("F")
I am not sure what you are trying to do here, but this statement does nothing. I was expecting it to error but it did not even do that. If you intend to loop values in column F, then you need to defing the range you want to loop, eg.
Code:
Dim rng As Range, a As Range
Set rng = Range("F2":F100")
    For Each a In rng
 
Last edited:
Upvote 0
Hi & welcome to MrExcel.
Is this what you're after
Code:
Sub Pending()
Dim r As Long
Dim msg As String, i As Long, a As Variant
msg = ""
For i = 2 To 100
   If Range("E" & i) <> "" And Cells(i, 6).Value = "" Then
      msg = msg & Range("D" & i) & " " & Range("E" & i) & vbLf
   End If
Next i

MsgBox msg

End Sub
 
Upvote 0
Dear Fluff ,

May you advise how to un-limit number of character in msgbox? I have tried below codes but msgbox can not show all texts. Thanks you in advance sir


Sub Pending()
Dim r As Long
Dim msg As String, i As Long, a As Variant
msg = ""
For i = 13 To 100000
If Range("F" & i) <> "" And Cells(i, 14).Value = "" Then
msg = msg & Range("E" & i) & " " & Range("F" & i) & " " & Range("G" & i) & " " & Range("K" & i) & vbLf
End If
Next i


MsgBox msg


End Sub
 
Upvote 0
You cannot "Un-Limit" a message box.
One option would be to look at using a textbox on a userform, but with the amount of data you are looking at, you may hit problems further problems.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top