Cannot run Visual Basic Macro because of syntax error

sactogroove

New Member
Joined
May 25, 2012
Messages
2
Just reviewed Mr. Excel's YouTube demo on building macros to change upper case to lower case, etc. Received response in title. I use 2007 Excel on a PC. How can I effect a syntax change to effect results?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Jeff-
Here it is:

Application.Run "PERSONAL.XLSB!LowerSelection"
Range("A3:E4").Select
ActiveCell.Offset(-1, 0).Rows("1:1").EntireRow.Select
Selection.Delete Shift:=xlUp
ActiveCell.Select

Sub UpperSelection()
For Each cell In Selection
If Not cell.HasFormula Then
cell.Value = UCase(cell.Value)
End If
Next cell
End Sub
Sub Macro1()
'Sub ProperSelection()
For Each cell In Selection
If Not cell.HasFormula Then
cell.Value = _
Application_
.WorksheetFunction_
.Proper (cell.Value)
End If
Next cell
End Sub

Thanks in advance.
 
Upvote 0
First, both of these run as expected, but the difference in what you posted, you did not have the variables declared so added the Dim statements. I'm not saying that is the problem, but you should declare your variables.

Now second, what are you trying to do with all that first part before the Upper and Proper subs? What is its connection to the Subs?

Is this something you are going to have other people use? Because using your Personal.xlsb is only only your computer and therefore others would not be able to access that procedure. How about placing your procedures in a regular module.

Code:
Sub UpperSelection()
    Dim cell As Range
    For Each cell In Selection
        If Not cell.HasFormula Then
            cell.Value = UCase(cell.Value)
        End If
    Next cell
End Sub

Code:
Sub ProperSelection()
    Dim cell As Range
    For Each cell In Selection
        If Not cell.HasFormula Then
            cell.Value = Application.WorksheetFunction.Proper(cell.Value)
        End If
    Next cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,678
Members
449,248
Latest member
wayneho98

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