Read any leading comma in Cell in VBA UDF

Status
Not open for further replies.

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,052
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I'm still having trouble with this... found this code

Code:
Sub AddCommaToESIID()

    Dim rCell As Range

    If TypeName(Selection) = "Range" Then
        For Each rCell In Selection.Cells
            If Not rCell.HasFormula Then
                rCell.Value = "," & rCell.Value
            End If
        Next rCell
    End If

End Sub

I'm not sure how to apply that, or test if it works.
Wouldn't I need to pass something in?
Any help appreciated.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
what are you actually trying to do ??
Simply add a leading comma ??
 
Upvote 0
No, I'm comparing the cell contents against a database that my be different (e.g. data corrected)
So I can't say If Cell(x,y) = ImportedData then
I need If (Cell(x,y) = ImportedData) Or ("'" & Cell(x,y) = ImportedData) then
It's quite surprising how much longer this takes, so the above routine may have been better.it's very frustrating as I think Excel should read what is in the worksheet correctly.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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