VBA - Format Zip Code for BookMark

SpeedyFingers

New Member
Joined
Mar 26, 2012
Messages
38
Please help. I keep getting the "Else without If" Error and not sure how this code works. :p



Code:
For Each oBookMark In oDoc.Bookmarks
        Set objX = wsData.Rows(1).Find(oBookMark.Name, LookIn:=xlValues, lookat:=xlWhole)
        If Not objX Is Nothing Then
            Select Case oBookMark
                Case "NetToServicer", "PurchasePrice", "MaxCommission", "JrLien", _
                    "HOALiens", "Repairs", "Termite", "RelocationAmount", "CashContribution", _
                    "CertifiedFunds", "PromissoryNote", "ClosingCost", "ClosingCost2", "TotalIndebtedness", "TotalIndebtedness2", _
                    "PromissoryNote2", "PromissoryNote3", "CashContribution2", "CashContribution3", "RelocationAmount2500", "RelocationAmount3000", "RelocationAmount2", _
                    "RelocationAmount30002", "RelocationAmount30003", "RelocationAmount30004", "NetToServicer2", "RelocationAmount30005", "ClosingCost3", "ClosingCost4", _
                    "ClosingCost5", "PromissoryNote4", "CashContribution5", "CashContribution5", "JrLien2", "HOAFee"
                    Dim thiz
                    'MsgBox oBookMark.Range.Text
                    thiz = Format(wsData.Cells(rng2.Row, objX.Column), "$#,##0.00")
                    'MsgBox thiz
                    'MsgBox (oBookMark.Range.Text = Format(wsData.Cells(rng2.Row, objX.Column), "$#,##0.00"))
                    oBookMark.Range.Text = thiz
                Case Else
            Select Case oBookMark
                Case "PropertyZip", "MailingAddressZip"
                    Dim zip
                    'MsgBox oBookMark.Range.Text
                    zip = Format(wsData.Cells(rng2.Row, objX.Column), "0000")
                    'MsgBox zip
                    'MsgBox (oBookMark.Range.Text = Format(wsData.Cells(rng2.Row, objX.Column), "0000"))
                    oBookMark.Range.Text = zip
                Case Else
                    oBookMark.Range.Text = wsData.Cells(rng2.Row, objX.Column)
                End Select
        Else
            MsgBox "Bookmark '" & oBookMark.Name & "' not found", vbOKOnly + vbCritical, "error"
            GoTo Tidy_Exit
        End If
    Next oBookMark
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,216,765
Messages
6,132,588
Members
449,737
Latest member
naes

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