zero appears in the Msg box

KlausW

Active Member
Joined
Sep 9, 2020
Messages
449
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone In an Msg box, some information from some cells has, see the VBA code.
This works well, but when the cells are empty a zero appears in the Msg box see image, can I hide them?

Any help will be appreciated

Best regards Klaus W

VBA Code:
Sub Afrundetrektangel1_Klik()

If Range("ai52") = 0 Then Range("ai75") = ""

MsgBox Range("Ai52") & vbNewLine & Range("Ai53") & vbNewLine & Range("Ai54") & vbNewLine & Range("Ai55") & vbNewLine & Range("Ai56") & vbNewLine & Range("Ai57") & vbNewLine & Range("Ai58") & vbNewLine & Range("Ai59") & vbNewLine & Range("Ai60") & vbNewLine & Range("Ai61") & vbNewLine & Range("Ai62") & vbNewLine & Range("Ai63") & vbNewLine & Range("Ai64") & vbNewLine & Range("Ai65") & vbNewLine & Range("Ai66") & vbNewLine & Range("Ai67") & vbNewLine & Range("Ai68") & vbNewLine & Range("Ai69") & vbNewLine & Range("Ai70") & vbNewLine & Range("Ai71") & vbNewLine & Range("Ai72") & vbNewLine & Range("Ai73") & vbNewLine & Range("Ai74") & vbNewLine & Range("Ai75"), , "Symbol oversigt tjeneste-frihed"

Sheets(Format(Now, "mmmm")).Select 

End Sub
 

Attachments

  • Pic1.PNG
    Pic1.PNG
    13.3 KB · Views: 9
Too risky I would say, Alex. vba Filter is a "contains" (or "does not contain") filter.
Example: If AI61 was "P for AFS. P 70" instead of "P for AFS. P 17" then it would be omitted from the message box.
Thanks Peter. I was kind of excited that I had finally found a use for the VBA Filter function but that puts a bit of a damper on it ;).
I know you managed to make it work but I would probably just stick to using a loop rather than jump through all those hoops.
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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