?
Solved

excel macro

Posted on 2013-01-17
6
Medium Priority
?
149 Views
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
     c.ClearContents
  '   Next c
'End If
             Insert_Block
       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

0
Comment
Question by:jquestion
[X]
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
6 Comments
 
LVL 7

Expert Comment

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

Author Comment

by:jquestion
ID: 38788446
0
 

Author Comment

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

Accepted Solution

by:
Steve earned 2000 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.
TestMacro.xlsm
0
 

Author Closing Comment

by:jquestion
ID: 38805443
Awesome, Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

762 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