Need excel expert

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try like this

Code:
Sub Stars()
Dim i As Long
For i = 1 To 4
    Cells(i, 1).Resize(, i).Value = "*"
Next i
End Sub
 

UniMord

Active Member
Joined
May 6, 2002
Messages
309
If you want all your asterisks in a single column, enter in row 1: =REPT("*", ROW()) and drag down.

If you want your asterisks in separate columns, enter in A1: =IF(COLUMN()<= ROW(), "*", "") and drag as far down and right as you like.
 
Last edited:

UniMord

Active Member
Joined
May 6, 2002
Messages
309
Only if you need all your asterisks in a single cell, will you be forced to use VBA. To extend VoG's solution above, you can use the following function:

Code:
Function Stars(num&) As String
    Dim i&
 
    For i = 1 To num
        Stars = Stars & String(i, "*") & vbNewLine
    Next i
    Stars = Left(Stars, Len(Stars) - Len(vbNewLine))
End Function

Just make sure that you have wrap text on, otherwise you'll just get them all in a row.
 

kashif.special2005

Active Member
Joined
Oct 26, 2009
Messages
435

ADVERTISEMENT

Thanks for reply

I want to do this through procedure

I want to create prymide

like Capital A sign

kashif
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,779
To create a pyramid (all in one column), create a right triangle (like UniMord's formula) and then format the cells to align Center.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,779
If you have
A1 = "*"
A2 = "**"
A3 = "***"
A4 = "****"

it will look like a right triangle if A1:A4 are set to align Left (the default) but will look like an isosceles triangle if they are set to align center.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,614
Messages
5,523,906
Members
409,542
Latest member
Shezz01

This Week's Hot Topics

Top