Hi all
I have this macro that creates a column of circles, one for each cell in the range selected.
I don't know how to edit it to make it so that the result is no more than 5 columns wide and then x amount of rows depending on how many cells are selected.
Can someone help, please?
Many thanks
Sam
I have this macro that creates a column of circles, one for each cell in the range selected.
I don't know how to edit it to make it so that the result is no more than 5 columns wide and then x amount of rows depending on how many cells are selected.
Can someone help, please?
Code:
Sub Condit_Shapes()
Dim c, Rng As Range
Dim W, H, Gut As Integer
Dim Shp As String
Dim X, X_Start, Y As Integer
Dim rw, cl, rw_counter, cl_counter As Integer
Dim fnt, fnt_color As String
Dim fnt_size As Integer
'Set the range
Set Rng = Selection
'Count the columns and rows
rw_counter = Selection.Rows.Count
cl_counter = Selection.Columns.Count
'Set the width, height, shape type and gutter
W = 30
H = 30
Shp = msoShapeOval
Gut = 5
'Set the font characteristics
fnt = "BBC Reith Sans cd"
fnt_size = 8
fnt_color = 4210752
'Set the X,Y co-ordinates
X_Start = Selection.Cells(1, cl_counter).Offset(, 2).Left
X = X_Start
Y = Selection.Cells(1, 1).Top
'iterate through rows
For rw = 1 To rw_counter
'iterate through columns
For cl = 1 To cl_counter
'If the cell has formatting, if not, create shape
If Selection.Cells(rw, cl).Value <> "" Then
With ActiveSheet.Shapes.AddShape(Shp, X, Y, W, H)
.Name = Str(rw) + "," + Str(cl)
.Fill.ForeColor.RGB = Selection.Cells(rw, cl).DisplayFormat.Interior.Color
'.Fill.ForeColor.TintAndShade = -0.2
'.Adjustments(1) = 0.05
.Line.Visible = msoFalse
With .TextFrame
.HorizontalAlignment = xlHAlignLeft
.VerticalAlignment = xlVAlignTop
End With
End With
Else:
With ActiveSheet.Shapes.AddShape(Shp, X, Y, W, H)
.Name = Str(rw) + "," + Str(cl)
.Fill.ForeColor.RGB = 12566463
'.Fill.ForeColor.TintAndShade = -0.2
'.Adjustments(1) = 0.05
.Line.Visible = msoFalse
End With
End If
X = X + W + Gut
Next cl
X = X_Start
Y = Y + H + Gut
Next rw
End Sub
Many thanks
Sam