Message Box value to percentage and currency

gilquenanoviii

New Member
Joined
May 18, 2022
Messages
26
Office Version
  1. 2021
Platform
  1. Windows
Hi everyone. I am new here.
Please help me as I need to do and finish a report.

How will i be able to change the format of YTD Sales, MTD, Sales to $ currency format
and the TY vs LY LFL , Con. to Dept to Percentage Format?

Please help.

1652862786754.png


this is the formula that is in use for this message box


Sub ANKER()
Dim xRg As Range
Dim xCell As Range
Dim xStr As String
Dim xRow As Long
Dim xCol As Long
Worksheets("ELECTRONICS_DATA").Activate
Set xRg = Range("n16:m24")
For xRow = 1 To xRg.Rows.Count
For xCol = 1 To xRg.Columns.Count
xStr = xStr & xRg.Cells(xRow, xCol).Value & vbTab
Next
xStr = xStr & vbCrLf
Next
Worksheets("MAP").Activate
MsgBox xStr, vbInformation
End Sub


thank you so much in advance
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,
welcome to forum

Not sure if this is what you are trying to do but assuming the ranges are all formatted in manner required then trying using the Text property of the Range to return what you see in the cell.

VBA Code:
Sub ANKER()
    Dim xRg         As Range, xCell As Range
    Dim xRow        As Long, xCol As Long
    Dim xStr        As String
   
    Set xRg = Worksheets("ELECTRONICS_DATA").Range("n16:m24")
   
    For xRow = 1 To xRg.Rows.Count
        For xCol = 1 To xRg.Columns.Count
            xStr = xStr & xRg.Cells(xRow, xCol).Text & vbTab
        Next
        xStr = xStr & vbCrLf
    Next
   
    Worksheets("MAP").Activate
   
    MsgBox xStr, vbInformation
End Sub

Dave
 
Upvote 0
Hi
just another IDEA
VBA Code:
'Option Explicit

Sub ANKER()
    Dim xRg As Range
    Dim xCell As Range
    Dim xStr As String
    Dim xRow As Long
    Dim xCol As Long
    Worksheets("ELECTRONICS_DATA").Activate
    Set xRg = Range("n16:m24")
    For xRow = 1 To xRg.Rows.Count
        For xCol = 1 To xRg.Columns.Count
        If xRg.Cells(xRow, xCol).Value = "YDT" Or xRg.Cells(xRow, xCol).Value = "MDT" Then
        xStr = xStr & xRg.Cells(xRow, 1).Value & vbTab & vbTab
        xStr = xStr & "$" & xRg.Cells(xRow, 2) & vbTab
        Exit For
        Else
         If xRg.Cells(xRow, xCol).Value = "TY vs LY LFL" Or xRg.Cells(xRow, xCol).Value = "Con" Then
        xStr = xStr & xRg.Cells(xRow, 1).Value & vbTab & vbTab
        xStr = xStr & "%" & xRg.Cells(xRow, 2) & vbTab
        Exit For
        Else
            xStr = xStr & xRg.Cells(xRow, xCol).Value & vbTab
            End If
            End If
        Next
        xStr = xStr & vbCrLf
    Next
    Worksheets("MAP").Activate
    MsgBox xStr, vbInformation
End Sub
 
Upvote 0
Hi
just another IDEA
VBA Code:
'Option Explicit

Sub ANKER()
    Dim xRg As Range
    Dim xCell As Range
    Dim xStr As String
    Dim xRow As Long
    Dim xCol As Long
    Worksheets("ELECTRONICS_DATA").Activate
    Set xRg = Range("n16:m24")
    For xRow = 1 To xRg.Rows.Count
        For xCol = 1 To xRg.Columns.Count
        If xRg.Cells(xRow, xCol).Value = "YDT" Or xRg.Cells(xRow, xCol).Value = "MDT" Then
        xStr = xStr & xRg.Cells(xRow, 1).Value & vbTab & vbTab
        xStr = xStr & "$" & xRg.Cells(xRow, 2) & vbTab
        Exit For
        Else
         If xRg.Cells(xRow, xCol).Value = "TY vs LY LFL" Or xRg.Cells(xRow, xCol).Value = "Con" Then
        xStr = xStr & xRg.Cells(xRow, 1).Value & vbTab & vbTab
        xStr = xStr & "%" & xRg.Cells(xRow, 2) & vbTab
        Exit For
        Else
            xStr = xStr & xRg.Cells(xRow, xCol).Value & vbTab
            End If
            End If
        Next
        xStr = xStr & vbCrLf
    Next
    Worksheets("MAP").Activate
    MsgBox xStr, vbInformation
End Sub
OMG THANK YOU SO MUCH YOU SAVED MY LIFE!
 
Upvote 0
Hi,
welcome to forum

Not sure if this is what you are trying to do but assuming the ranges are all formatted in manner required then trying using the Text property of the Range to return what you see in the cell.

VBA Code:
Sub ANKER()
    Dim xRg         As Range, xCell As Range
    Dim xRow        As Long, xCol As Long
    Dim xStr        As String
  
    Set xRg = Worksheets("ELECTRONICS_DATA").Range("n16:m24")
  
    For xRow = 1 To xRg.Rows.Count
        For xCol = 1 To xRg.Columns.Count
            xStr = xStr & xRg.Cells(xRow, xCol).Text & vbTab
        Next
        xStr = xStr & vbCrLf
    Next
  
    Worksheets("MAP").Activate
  
    MsgBox xStr, vbInformation
End Sub

Dave
THIS IS THE ONE I USED. THANK YOU SO MUCH GUYS! YOUVE BEEN REALLY HELPFUL!
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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