Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Need to run a Macro to ....

Hello,

I need to run a macro on all the Cells of a sheet to run the PROPER function
on each cell and if the length of that Cell is zero to stick a blank space "
" inside the cell. Thru Help I find a sample and by simple modification I
inserted into my macro but deoes not work and gives me run time error 1004.
Here is my sample code:

Sub FixUp()
Dim myRange As Range
Set myRange = Worksheets("PtTable").Range("A1:AA500")
myRange.Formula = "=Proper()"
End Sub

Would you please help me on my problem?

--
Jeff B Paarsa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Need to run a Macro to ....

Sub FixUp()
Dim myRange As Range
dim cell as range
dim text as string
Set myRange = Worksheets("PtTable").Range("A1:AA500")
for each cell in myrange.cells
text = cell.value
if len(text)=0 then
cell.Value = " "
else
cell.value =WorksheetFunction.Proper(text)
end if
next
End Sub





"Jeffery B Paarsa" wrote in message
...
Hello,

I need to run a macro on all the Cells of a sheet to run the PROPER
function
on each cell and if the length of that Cell is zero to stick a blank space
"
" inside the cell. Thru Help I find a sample and by simple modification I
inserted into my macro but deoes not work and gives me run time error
1004.
Here is my sample code:

Sub FixUp()
Dim myRange As Range
Set myRange = Worksheets("PtTable").Range("A1:AA500")
myRange.Formula = "=Proper()"
End Sub

Would you please help me on my problem?

--
Jeff B Paarsa


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Need to run a Macro to ....

Jeff,
The function call requires a parameter, viz =Proper(A1)
What you actually require is

Sub FixUp()
Dim myRange As Range
For Each myRange In Worksheets("PtTable").Range("A1:AA500")
If IsEmpty(myRange) Then
myRange.Value = " "
Else
myRange.Value =
Application.WorksheetFunction.Proper(myRange.value )
End If
Next myRange
End Sub



"Jeffery B Paarsa" wrote:

Hello,

I need to run a macro on all the Cells of a sheet to run the PROPER function
on each cell and if the length of that Cell is zero to stick a blank space "
" inside the cell. Thru Help I find a sample and by simple modification I
inserted into my macro but deoes not work and gives me run time error 1004.
Here is my sample code:

Sub FixUp()
Dim myRange As Range
Set myRange = Worksheets("PtTable").Range("A1:AA500")
myRange.Formula = "=Proper()"
End Sub

Would you please help me on my problem?

--
Jeff B Paarsa

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Need to run a Macro to ....

Or, instead of jumping out to the worksheet function PROPER, you can use a
built-in VB function to do the same thing. Just replace this line of code...

myRange.Value = Application.WorksheetFunction.Proper(myRange.Value )

with this one...

myRange.Value = StrConv(myRange.Value, vbProperCase)

--
Rick (MVP - Excel)


"Kevin Beckham" wrote in message
...
Jeff,
The function call requires a parameter, viz =Proper(A1)
What you actually require is

Sub FixUp()
Dim myRange As Range
For Each myRange In Worksheets("PtTable").Range("A1:AA500")
If IsEmpty(myRange) Then
myRange.Value = " "
Else
myRange.Value =
Application.WorksheetFunction.Proper(myRange.value )
End If
Next myRange
End Sub



"Jeffery B Paarsa" wrote:

Hello,

I need to run a macro on all the Cells of a sheet to run the PROPER
function
on each cell and if the length of that Cell is zero to stick a blank
space "
" inside the cell. Thru Help I find a sample and by simple modification
I
inserted into my macro but deoes not work and gives me run time error
1004.
Here is my sample code:

Sub FixUp()
Dim myRange As Range
Set myRange = Worksheets("PtTable").Range("A1:AA500")
myRange.Formula = "=Proper()"
End Sub

Would you please help me on my problem?

--
Jeff B Paarsa


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"