[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

excel macro

Posted on 2013-01-17
6
Medium Priority
?
154 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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!
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

656 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