VBA to work on multiple lines

Hi all,

I will try make this as clear as possible as I don’t think it is too hard to explain.


I have a macro to add a comment to a cell and insert a picture inside it as below;

Sub Img_in_Commentbox()

With Application.FileDialog(msoFileDialogFilePicker)

         .AllowMultiSelect = True          

         .InitialFileName = CurDir         ‘directory to open the window

         .Filters.Clear                    ‘Cancel the filter

         .Filters.Add Description:=”Images”, Extensions:=”*.jpg”, Position:=1

         .Title = “Choose image”


         If .Show = -1 Then TheFile = .SelectedItems(1) Else TheFile = 0

    End With

‘No file selected

If TheFile = 0 Then

MsgBox (“No image selected”)

Exit Sub

End If


    Range(“F36”).Comment.Visible = False

[F36].Comment.Shape.Fill.UserPicture TheFile

End Sub


This works perfect but I have over 300 lines to do this same macro for.

Is there a way to modify the formula so I can just make it so if the user clicks to add the photo on line ‘x’ then comment will only be made on line ‘x’

‘x’ being whatever line number.

By: Shane

489 thoughts on “VBA to work on multiple lines

  1. Aparelho Com Iptv

    Ponto IPTV a melhor programacao de canais IPTV do Brasil, filmes, series, futebol, lutas, shows, documentarios em alta definicao de imagem e som em SD, HD, FULL HD, 4K. compativel com todos aparelhos do mercado Brasileiro.

  2. Neomi

    Nice post. I learn something new and challenging on sites I stumbleupon on a daily basis. It as always interesting to read articles from other writers and use something from their sites.

  3. Edna

    It as hard to find expert persons by this matter, then again you sound like you already make out what you are talking about! Thanks

  4. Haley

    wonderful issues altogether, you simply gained a logo new reader. What might you recommend in regards to your submit that you made some days in the past? Any sure?

Comments are closed.