a macro to insert an arrow

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
826
Office Version
  1. 365
Platform
  1. Windows
Hi
I have a macro highlight a cell in A that has the current date when the sheet opens. I want to have and arrow inserted 4 cells to the right
I used the record a macro to insert an arrow in the proper cell.
VBA Code:
Sub forarrow()
       ' make arrow
    ActiveCell.Offset(0, 4).Range("A1").Select
  ActiveSheet.Shapes.AddShape(msoShapeLeftArrow, 247.2, 75.6, 52.8, 17.4).Select   
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveCell.Offset(0, -4).Range("A1").Select
End Sub
It works great, except it drops down 44 cells and inserts the arrow. then it goes back up to where it was supposed to insert it and moves to the left like its supposed to.
I can't see why it drops 44 cells

mike
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Something going on with that specific workbook. You could try selecting the first 44 rows, then DELETE.

Then run macro again to see what occurs.

What happens also if you run that macro in a new, clean workbook ?
 
Upvote 0
ActiveSheet.Shapes.AddShape(msoShapeLeftArrow, 247.2, 75.6, 52.8, 17.4).Select
That way the arrow always stays in the same position.

According to your comment the cell in column A is already selected.
I have a macro highlight a cell in A that has the current date when the sheet opens

Then try:
VBA Code:
Sub forarrow_v0()
  ' make arrow
  ActiveSheet.Shapes.AddShape(msoShapeLeftArrow, ActiveCell.Offset(, 4).Left, ActiveCell.Top, 52.8, 17.4).Select
  With Selection.ShapeRange.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(255, 0, 0)
    .Transparency = 0
    .Solid
  End With
End Sub
--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Upvote 0
Hi Logit,
I tried the macro in a new sheet and it goes where I want. I'll have to see why
Hi DanteAmor.
Yep the opening macro puts the cursor where I want the arrow. I will try your fix
I won't be able to try anything till tue. I thank you both for your reply

Wishing both a save and fun holiday.

mike
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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