excel macro

Posted on 2013-01-17
Last Modified: 2013-01-22
Hello, I am trying to create a macro that will change when the user only uses the drop down and it will populate the row with data from the vlookup. I have the following code but am stuck like braindead. Im learning and could use an experts help! Thanks!

Private Sub Worksheet_Change(ByVal NameBox As Range)
       Dim c As Range
       Range ("c4:m4")
     'For Each c In Range("c4:m4")
     'If Not IsNumeric(c) Then
  '   Next c
'End If
       End Sub

Option Explicit
    Const SUMMARY_COLOR = 48
    Const DETAIL_COLOR = 36

Sub Insert_Block()

   With Range("C4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,3,FALSE)"
      .Value = .Value
       End With
      With Range("D4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,4,FALSE)"
      .Value = .Value
       End With
      With Range("E4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,5,FALSE)"
      .Value = .Value
       End With
      With Range("F4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,6,FALSE)"
      .Value = .Value
       End With
      With Range("G4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,7,FALSE)"
      .Value = .Value
       End With
      With Range("H4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,8,FALSE)"
      .Value = .Value
       End With
      With Range("I4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,9,FALSE)"
      .Value = .Value
       End With
      With Range("J4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,10,FALSE)"
      .Value = .Value
       End With
      With Range("K4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,11,FALSE)"
      .Value = .Value
       End With
      With Range("L4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,12,FALSE)"
      .Value = .Value
       End With
      With Range("M4")
      .Formula = "=VLOOKUP( B4,'EXCEPTION % SUMMARY'!$A:$N,13,FALSE)"
      .Value = .Value
    End With
End Sub

Open in new window

Question by:jquestion
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 38787808
could you pl attach yr excel sheet with macro for fast reply!

Author Comment

ID: 38788446

Author Comment

ID: 38788571
This is the file Im trying to get to work. any help would be greatly appreciated
LVL 24

Accepted Solution

Steve earned 500 total points
ID: 38803103
OK, attached is a "corrected" version of the code you are trying to accomplish.

There are plenty of alternatives to get the job done.

But this is close to what you were trying to do.

Author Closing Comment

ID: 38805443
Awesome, Thanks!

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Modify Text File with Excel Macro 13 46
I need to extract city and state from a cell in Excel 6 31
sort time order 10 44
Resolving #VALUE error in spreadsheet 2 17
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question