Results 1 to 4 of 4

Thread: Help Creating A Macro
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Dec 2015
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Help Creating A Macro

    First let me say, I know very little about macros. I have a few personal macros that I use which I found online over the years, but other than doing minor changes to them I have just copied them from other sources and assigned a shortcut to them to run. I don't know how to actually create one from scratch myself. So I really need help since the person I spoke with in my IT department said that a macro could do what I need, but she was unable to help since she doesn't have a lot of experience with them.

    Here is basically what I am trying to do....I have a list of values in Column B, I would like to make it so that if you click a certain cell in column B it would move my cursor and enter a specific value into F2. e.g.
    B3:B8=
    10ft x 5ft - $1,255
    10ft x 6.4ft - $1,325
    12ft x 5ft - $1,325
    12ft x 6.4ft - $1,395
    14ft x 5 ft - $1,425
    14ft x 6.4ft - $1,495

    If I click on B3, I want it to enter $1,255 into F2. If I click on B4, I want it to enter $1,325 into F2. etc. I have over 50 values in column B to choose from. If someone can write a basic macro, I know enough to edit the macro and change the source cell and the value. Also, would I need a separate macro for each B value, or can they all be put into a single macro?

    I initially thought I could create a hyperlink from B3 to send my cursor to F2 and then enter an assigned value automatically to the cell, but I've been told hyperlinks don't work that way. So I think a macro is my only option unless someone has other ideas.

    As for other information you may need to do a macro....the filename is Trailers.xlsm, the sheet name is Trailer. I'm not sure if you need any other information from me. If anyone can help it would be greatly appreciated.

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,078
    Post Thanks / Like
    Mentioned
    469 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Help Creating A Macro

    How about
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
       If Not Intersect(Target, Range("B3:B50")) Is Nothing Then
          Range("F2").Value = Target.Offset(, 1).Value
          Cancel = True
       End If
    End Sub
    This needs to go in the relevant sheet module & works when you double click in rangeB3:B50
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    New Member
    Join Date
    Dec 2015
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Help Creating A Macro

    Thank you. I greatly appreciate the help.

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,078
    Post Thanks / Like
    Mentioned
    469 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Help Creating A Macro

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •