Solved

excel macro

Posted on 2013-01-17
6
111 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
  • 3
6 Comments
 
LVL 7

Expert Comment

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

Author Comment

by:jquestion
Comment Utility
0
 

Author Comment

by:jquestion
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Awesome, Thanks!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now