Macro named argument - Error

aavvijit

Board Regular
Joined
Mar 23, 2009
Messages
75
Hi,

Can some please help me to correct this mcro code - this I am using to fill a range with alphabatical list.

Code:
Sub AlphaFill()
    Dim Cell, CellChars
    Dim Default, Prompt, Title
    Dim rangeSelected As Range
    Dim UpperCase As Boolean
    Title = "AlphaFill Cell Selection"
    Default = Selection.Address
    Prompt = vbCrLf _
      & "Use mouse in conjunction with " _
      & "SHIFT and CTRL keys to" & vbCrLf _
      & "click and drag or type in name(s) " _
      & "of cell(s) to AlphaFill" & vbCrLf & vbCrLf _
      & "Currently selected cell(s): " & Selection.Address
    On Error Resume Next
    Set rangeSelected = InputBox(Prompt, Title, Default, Type:=8)
    If rangeSelected Is Nothing Then Exit Sub
    UpperCase = True
    Randomize
    For Each Cell In rangeSelected
        CellChars = Chr(64 + Int((Rnd * 26) + 1))
        If Not UpperCase Then CellChars = LCase(CellChars)
        Cell.Value = CellChars
    Next
End Sub

Above code is giving error "Named argument error" on following line : "Type:=8"

I am using Excel 2003.

Please help where the code is going wrong.

Regards,
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I believe that you are trying to use the Application.InputBox Method, but are instead calling the InputBox function.

Put Application. in front of the word InputBox.
 
Upvote 0
Thanks Glenn,

It is wonderfully solved, Can I request another small issue.

I want to put "the message box" promt to select range in this macro, Please help how to do that.

Code:
Public Sub Autofill()
Dim A As Long
Dim B As Long
Dim C As Long
Dim s As String
Dim row As Long
Dim rangeSelected As Range

Application.ScreenUpdating = False
With Selection
For A = 65 To 90
           row = row + 1
           s = Chr(A) & Chr(B) & Chr(C)
           Range("M" & CStr(row)).Value = s
Next
Application.ScreenUpdating = True
End With
End Sub

Thanks,
 
Upvote 0
Aren't you asking how to do exactly what your previous macro does?
 
Upvote 0
yes, But some difference,

My previous macro put the alphabet in a randomly manner in the selected range, but with the next macro I want to put the alphabet in a sequential manner in the selected range.

Thant means I want to put like this - A-B-C-D........ in the selected rows.

Please help.
 
Upvote 0
What I meant was, your request was for help
to put "the message box" promt to select range
You already know how to do that, because you are already doing that in the previous macro.
 
Upvote 0
Let me just try to get things clear ...

1) do you have a macro, named Autofill, in which you prompt the user to select a range?

2) are you saying that you do not know how to prompt the user for a range in a second macro?
 
Upvote 0
I think he's saying he needs an Application.InputBox with a prompt of "the message box", type:=8, then he wants code to fill each cell in turn with "A", "B", "C", etc.
 
Upvote 0
Yes, Mr. Ruddles is right,

In my second macro I want to put a message box prompt which will fill the alphabet (A, B, C, D ...........) in a sequential manner in the selected range.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

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