VBA codes help

agasi

New Member
Joined
Nov 22, 2016
Messages
48
I have several issues here.

What I need is two vba codes:

1. I need a macro to find a relative position to insert a shape to assign a macro (called addrow): The below code is not dynamic.

2. Another macro to copy the above macro into multiple workbooks saved under a folder. I just copied below code manually into a new workbook. But when I clicked the macro assigned shape, I had an error message. "Cannot run the macro 'addrow'. The macro may not be available'

Sub ADDLINEBELOW()
Worksheets("xxx").Activate
Dim i As Integer
Dim s As Range
Dim cl As Range
Do
i = i + 1

Loop Until Cells(i, "b").Value = "Totals:"
Cells(i, "b").Offset(0, -1).Select
Set s = Cells(i, "b").Offset(0, -1)
With Selection


For Each Ccl In s
With ActiveSheet.Shapes.AddShape(msoShapeRectangle, 149.1666929134, 692.5, _
101.6666141732, 30.8333070866).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Click to insert row "

End With
Next

With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 12). _
ParagraphFormat
.FirstLineIndent = 0
.Alignment = msoAlignLeft
End With
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 12).Font
.NameComplexScript = "+mn-cs"
.NameFarEast = "+mn-ea"
.Fill.Visible = msoTrue
.Fill.ForeColor.ObjectThemeColor = msoThemeColorLight1
.Fill.ForeColor.TintAndShade = 0
.Fill.ForeColor.Brightness = 0
.Fill.Transparency = 0
.Fill.Solid
.Size = 11
.Name = "+mn-lt"
End With
Selection.OnAction = "addrow"
End With

End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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