Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all 49926 articles
Browse latest View live

Script to copy a column of 12 values into 60 cell range

$
0
0
At this point I'm not sure if I need a macro or a VBA formula, but if I could throw myself on your mercy any help would be much appreciated.

The problem:
I have a list of 12 umpires that I want to spread evenly through a range of 60 cells (20 matches with 3 umpires a match). The only caveat to that being that no umpire can repeat within 5 cells, as two matches will run side by side so 6 umpires will be working at any one time. If it helps every umpire will get 5 slots over 60 cells.

I usually do this manually, but decided there must be a better way to achieve this.

I have attached a workbook which I think makes the problem clear.

Looking at the future, is there a possibility of creating a spread sheet where the numbers of matches and umpires vary, but you still spread the umpiring load across all available umpire?

Many thanks for any help.

Gilesumpire_schedule.xlsx

VBA code to seperate a cell

$
0
0
I need a VBA code to take everything after a certain word and put it in a new cell below it. The cell would have View More in it most of the time, and sometimes spaces will be messed up, so it will have a name after it but it should actually be in the cell under it. So if the name is A Maple, it will say View MoreA Maple. So the A Maple need to go in a cell below it. Any help is appreciated. Thanks

Need to Build Macro that Pulls Data from one Worksheet into a Second Worksheet

$
0
0
I have a mileage table that has distance values between two airports this worksheet is called "Mileage Chart" I have a second worksheet called "Mileage Calculator where the user inputs the origin and destination airport codes and the Macro should reference the "Mileage Chart" worksheet and return the intersecting value. I have gotten the Macro to work when it is placed in the "Mileage Chart" worksheet but I would like to have the Macro run from the "Mileage Calculator" worksheet. Can someone show me how to do this? Here is my code and my spreadsheet.

Option Explicit

Sub Find()

Dim rngRowFind As Range, rngColFind As Range

Set rngRowFind = Sheets("Mileage Chart").Range("B3:B53").Find(Range("C2"), LookIn:=xlValues)
Set rngColFind = Sheets("Mileage Chart").Range("C2:BA2").Find(Range("C1"), LookIn:=xlValues)

If Not rngRowFind Is Nothing And Not rngColFind Is Nothing Then _
Range("C3") = Cells(rngRowFind.Row, rngColFind.Column)

End Sub
Attached Files

Sheet name in Header

$
0
0
Hi-

I need a Macro to add the text "ASN:" followed by &[Tab] ,to pull in the sheet name, in the center section of the header.

I also need the footer to have Page &[Page] of &[Pages] in the center section.

Recording a Macro did not work.

VBA to Change Chart Color Scheme Based on Criteria for Business Dashboard

$
0
0
Hello,

I could not find a thread to help with my exact question. If one exists please point me in the right direction.

Problem/Question:

I am creating a dashboard for my business unit that will measure performance goals.
The data will change month to month and thus the dashboard graphs and information will automatically update.

I am looking for help with a vba script that will update the graph color scheme based on the business units overall score. ie. Overall score >90% Full chart is Green Theme, overall <90% but >75% is Yellow/Orange Theme, overall<75% is Red Theme.

I have attached an example file for reference.

Any and all help is much appreciated.

Regards,

Joel

Dashboard_1.xlsx

Macro to Hide a Column with a relative position

$
0
0
I am trying to hide a column titled "Test". This column is usually olumn E, but it is possible it can be moved to column D or F. If I use

Code:

Public Sub TestHide()
Range("E:E").EntireColumn.Hidden = True
End Sub

then column E is hidden, regardless of whether Test is moved left or right. The reason Test moves is due to the user inserting or deleting a column.

Trigger Worksheet Change by copy and paste

$
0
0
The following code seems to work fine if the user selects a value from the drop down cell in column T, but if that user then copies and pastes his selection into subsequent cells, it appears that the event is not trigger so the data validation does not get added to column S as it should. Could anyone provide some assistance to this? I am sure my code is a little redundant (still trying to learn all this). This code is on the actual sheet tab, just in case you didn't already know that.
Code:

Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("T:T")) Is Nothing Then
        If Target.Count > 1 Then
            Me.Unprotect Password:="password"
            Application.EnableEvents = False
            Target.Offset(0, -1).Validation.Delete
            Target.Offset(0, -1).Locked = True
            Application.EnableEvents = True
            Me.Protect Password:="password", AllowFiltering:=True
            Exit Sub
        Else:
            If Target.Value <> """" Then
            Me.Unprotect Password:="password"
            Application.EnableEvents = False
                If Target.Offset(0, 7).Value = "P" Then
                    Target.Offset(0, -1).Validation.Add Type:=xlValidateList, Formula1:="ITR1,ITR2,ITR3,ITR4,ITR5,ITR6,ITR7,ITR8,ITR9,ITR10,ITR11,ITR12,ITR13,ITR14,ITR15"
                    Target.Offset(0, -1).Locked = False
                Else: Target.Offset(0, -1).Validation.Delete
                    Target.Offset(0, -1).Locked = True
                End If
            End If
            Application.EnableEvents = True
            Me.Protect Password:="password", AllowFiltering:=True
        End If
    End If

End Sub

VBA to click link in IE table

$
0
0
Hi all. I am building a macro that will go to a particular county court website (depending on criteria in the worksheet), gather information about the subject case, and return the results to the worksheet. The worksheet will have the following columns (among others): State, County, Case Number, Status, Docket. The information is gathered from State, County, and Case Number, run through a function to determine which website to visit, then I ultimately want the code to search that case number and return the case status (Active, Pending, Dismissed, etc.) in the Status column, and a link to the docket in the Docket column.

The website links are on a different sheet (called "Websites").

The only way I can think to do this is to program the automation for each site individually, which I have no problem doing. However, of course, the 1st website I'm working with, I'm having issues. I'm able to get it to head to the website, enter in the case number, and hit submit, but then for some reason it won't click the case number link that appears in the table results.

Until I get past this part, I have turned off the loop in my code. Here's the code I have so far. The website I'm currently working with is Case Search. The information for the first case (found in row 2) is State = FL, County = Broward, and Case Number = CACE13021641.

Please take a look and tell me what you think I'm doing wrong.


Code:

Public Sub GetCaseStatus()


Dim IE As Object
Dim URL As String
Dim RowNum As Integer
Dim RowCount As Integer
Dim State As String
Dim County As String
Dim CountyList As Range
Dim CaseNum As String
Dim link As Object
Dim doc As Object


    Set CountyList = Worksheets("Websites").Range("C2:E150")
    Set IE = CreateObject("InternetExplorer.Application")
     

    RowNum = 2
    RowCount = ActiveSheet.UsedRange.Rows.Count

       

'    Do While RowNum <= RowCount
        State = ActiveSheet.Range("D" & RowNum).Value
        County = ActiveSheet.Range("E" & RowNum).Value
        CaseNum = ActiveSheet.Range("G" & RowNum).Value

        URL = CourtWebsite(State, County, CountyList)
       
        IE.navigate URL
        IE.Visible = True
        Do
        DoEvents
        Loop Until IE.readyState = 4
       
                             
        IE.document.GetElementById("ctl00_ContentPlaceHolder1_txtCaseNumber").Value = CaseNum
        IE.document.GetElementById("ctl00_ContentPlaceHolder1_sbmPublicCase").Click
   
             
        Do
        DoEvents
        Loop Until IE.readyState = 4
       
        Set doc = IE.document
       
               
       
        For Each link In doc.getElementsByTagName("table")
       
            If link.document.Title = CaseNum Then
                link.document.Links(0).Click
            End If
           
        Next link
                 
                       
      RowNum = RowNum + 1
       
             
'    Loop
   
End Sub


Here's the function to determine the correct website, if you're interested:


Code:

Public Function CourtWebsite(case_state As String, case_county As String, list As Range)

CourtWebsite = Application.WorksheetFunction.VLookup(case_state & "-" & case_county, list, 3, False)

End Function


Opening common files to save time

$
0
0
I want a macro that I will save
it on my desktop to open one of
my common files

I want to do this because my
files are into dub directories and
opening them is a long process

Also explain where in the macro
can i edit to open more than one
file

Bingo Lottery Conundrum

$
0
0
At work we run a lottery bingo where 30 people pick 6 numbers from a total of 30 numbers, the easy bit is highlighting a persons number when one is drawn using conditional formatting but I need to highlight a person if they have absolutely no chance of winning the game due to other people waiting on a number they require, for example;

Person1 is waiting for numbers 1 & 2 to come up
Person2 is waiting for number 1 to come up
Person3 is waiting for number 2 to come up


It is impossible for person1 to win as no matter which number is drawn (1 or 2) someone else will win and in this case they stop paying into the current game and start paying into the next game.

It can also be impossible for person1 to win if others are waiting for more than 1 number: -

Person1 is waiting for numbers 1,2,3 & 4 to come up
Person2 is waiting for number 1 & 2 to come up
Person3 is waiting for number 3 & 4 to come up

So how can this be solved programmatically or via formulas?

Thanks

Excel Macro to insert copied row to the cell I currently have highlighted

$
0
0
I have 4 rows that are on a "Resource" sheet need to be inserted into about 150 different variable locations across 20 different sheets. Here is the code I have so far the will copy it to one specific location (see below). I need help in making the macro insert these copied cells to which ever cell I currently have active. I'm still really new at VB programming so this probably something really simple to solve.

Code:

ActiveWindow.ScrollWorkbookTabs Position:=xlLast
    Sheets("Resource").Select
    Rows("13:16").Select
    Selection.Copy
    ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
    Sheets("BL100").Select
    Rows("13:13").Select
    Selection.Insert Shift:=xlDown
    Range("A1").Select
End Sub

VBA String variable paste into separate application

$
0
0
hello all

is it possible to have a string variable within the vba code and then take this variable and paste it into another application?

I had thought of placing the string variable in a new sheet and then copying it but I want the new sheet to be deleted and this clears the memory.

Any thoughts?

Jim

VBA - insert date

$
0
0
Hello,

I would like to ask some VBA help regarding date inserting. I would like that if Range("B13" & lastrow) is "" then Range("A13" & lastrow) show the Date?

InStr does not appear to be working

$
0
0
Hello,

After one hell of an education from this forum about the use of "InStr", I have written some code that incorporates this particular function.
However, it is deleting the rows that contain what I have specified, put simply, after looking at it for about 2 hours - I give up! Need to call in
the heavy artillery, I have attached a file that lists a range of cells in column A, each cell contains a string, I want the cells that contain the
string "ADJ SUB" to remain and any cell that does not contain this string, that entire row to be deleted. The code is there as well so anyone
can have a look at it and tell me what I am doing wrong, I have obviously missed something out. Any assistance would be greatly appreciated!
Attached Files

Detect messages from Outlook that are moved

$
0
0
Is it possible to determine which message in Outlook is moved and when?

I use Excel macro to import messages from Outlook and I want to sort messages by time when they are deleted, moved or sent.

Thanks!

Simple If-Then test giving unexpected results

$
0
0
Hi :) First time here and first time to any vba or coding forum. Been programming for 12 years now, mostly in VBA and C and this is the first time I've looked for help.

Its something so simple, yet for some reason I am not getting the results I expect. Hoping some of you could provide some insight.

I have a simple function that breaks down data into "Pie Slices" - percentages of the whole. To ensure I'm not losing information, I created a test to see if my Pie Slices total 100% (or 1). The Code is as follows:

Code:

For i = 1 To pCashTran_c
      pCashPer(i) = Round(pCashTranArray(i) / pTotalValue, 2)
      Test = Test + pCashPer(i)
Next
       
For i = 1 To pStockTran_c
      pStockPer(i) = Round((value * pStockTranArray(i)) / pTotalValue, 2)
      Test = Test + pStockPer(i)
Next

The test is:
Code:

If Test < 1 Then
    answer = MsgBox("Test is less than 1, " & Test, vbOKOnly)
ElseIf Test > 1 Then
    answer = MsgBox("Test is greater than 1, " & Test, vbOKOnly)
ElseIf Test = 1 Then
    answer = MsgBox("Test is a go", vbOKOnly)
End If

It started out simpler than that as
Code:

If Test <> 1 Then
, but a value of 1 would prompt the msgbox, so I broke it down. Pretty much, a value of 1 <b>may or may not</b> fail the <i>less than</i> test. It is not consistent. I feel that data is being lost, but the rounding of the values should prevent that, shouldn't it?

Simple If-Then test giving unexpected results

$
0
0
Hi :) First time here and first time to any vba or coding forum. Been programming for 12 years now, mostly in VBA and C and this is the first time I've looked for help.

Its something so simple, yet for some reason I am not getting the results I expect. Hoping some of you could provide some insight.

I have a simple function that breaks down data into "Pie Slices" - percentages of the whole. To ensure I'm not losing information, I created a test to see if my Pie Slices total 100% (or 1). The Code is as follows:

Code:

For i = 1 To pCashTran_c
      pCashPer(i) = Round(pCashTranArray(i) / pTotalValue, 2)
      Test = Test + pCashPer(i)
Next
       
For i = 1 To pStockTran_c
      pStockPer(i) = Round((value * pStockTranArray(i)) / pTotalValue, 2)
      Test = Test + pStockPer(i)
Next

The test is:
Code:

If Test < 1 Then
    answer = MsgBox("Test is less than 1, " & Test, vbOKOnly)
ElseIf Test > 1 Then
    answer = MsgBox("Test is greater than 1, " & Test, vbOKOnly)
ElseIf Test = 1 Then
    answer = MsgBox("Test is a go", vbOKOnly)
End If

It started out simpler than that as
Code:

If Test <> 1 Then
, but a value of 1 would prompt the msgbox, so I broke it down. Pretty much, a value of 1 may or may not fail the less than test. It is not consistent. I feel that data is being lost, but the rounding of the values should prevent that, shouldn't it?

Macro only works once

$
0
0
Hey,

I didn't write this code on my own but I found it in the web instead. Unfortunately the original coder is not available. So here is the code:

http://forum.sbrforum.com/handicappe...rt-league.html

Pinnacle-XML-feed-macro-01-27-2012.zip

The code is supposed to draw Pinnaclesports odds from an XML feed and convert it into readable material. On the User Input side I put in 'full' at Import type, click on the "Import Pinnacle Odds" and then the "Create odds Table" buttons but it only works once. If I try the same thing again an hour later or so it still provides me with the same information in the "Odds table". Only if I exit Excel and then open it back up it works properly again.

VBA Looping between Labels Userform

$
0
0
Hi,

I am new to VBA and hope that someone can help me.
I have a series of 12 different text boxes and labels within a userform that I would like to loop bewtween.
As I am not able to do this I have written the code out in full.

I would greatly appreciate if somebody were able to give me some assistance.

Many thanks,


Benedict
Code:

Private Sub ComboBox1_Change()
   
    On Error Resume Next
   

    Me.lblUnidade1 = Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 3, 0)
    Me.lblQuantOrig1 = Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 2, 0)
    Me.lblPreço1 = Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 4, 0)
    Me.lblPreço1.Caption = Format(lblPreço1, "Currency")
 
End Sub



Private Sub ComboBox10_Change()

On Error Resume Next

    Me.lblUnidade10 = Application.WorksheetFunction.VLookup(Me.ComboBox10, [Database], 3, 0)
    Me.lblQuantOrig10 = Application.WorksheetFunction.VLookup(Me.ComboBox10, [Database], 2, 0)
    Me.lblPreço10 = Application.WorksheetFunction.VLookup(Me.ComboBox10, [Database], 4, 0)
    Me.lblPreço10.Caption = Format(lblPreço10, "Currency")
End Sub

Private Sub ComboBox11_Change()

On Error Resume Next

    Me.lblUnidade11 = Application.WorksheetFunction.VLookup(Me.ComboBox11, [Database], 3, 0)
    Me.lblQuantOrig11 = Application.WorksheetFunction.VLookup(Me.ComboBox11, [Database], 2, 0)
    Me.lblPreço11 = Application.WorksheetFunction.VLookup(Me.ComboBox11, [Database], 4, 0)
    Me.lblPreço11.Caption = Format(lblPreço11, "Currency")
End Sub

Private Sub ComboBox12_Change()
   
On Error Resume Next

    Me.lblUnidade12 = Application.WorksheetFunction.VLookup(Me.ComboBox12, [Database], 3, 0)
    Me.lblQuantOrig12 = Application.WorksheetFunction.VLookup(Me.ComboBox12, [Database], 2, 0)
    Me.lblPreço12 = Application.WorksheetFunction.VLookup(Me.ComboBox12, [Database], 4, 0)
    Me.lblPreço12.Caption = Format(lblPreço12, "Currency")
End Sub

Private Sub ComboBox2_Change()
   
On Error Resume Next

    Me.lblUnidade2 = Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 3, 0)
    Me.lblQuantOrig2 = Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 2, 0)
    Me.lblPreço2 = Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 4, 0)
    Me.lblPreço2.Caption = Format(lblPreço2, "Currency")
End Sub

Private Sub ComboBox3_Change()
   
On Error Resume Next

    Me.lblUnidade3 = Application.WorksheetFunction.VLookup(Me.ComboBox3, [Database], 3, 0)
    Me.lblQuantOrig3 = Application.WorksheetFunction.VLookup(Me.ComboBox3, [Database], 2, 0)
    Me.lblPreço3 = Application.WorksheetFunction.VLookup(Me.ComboBox3, [Database], 4, 0)
    Me.lblPreço3.Caption = Format(lblPreço3, "Currency")
End Sub

Private Sub ComboBox4_Change()
   
On Error Resume Next

    Me.lblUnidade4 = Application.WorksheetFunction.VLookup(Me.ComboBox4, [Database], 3, 0)
    Me.lblQuantOrig4 = Application.WorksheetFunction.VLookup(Me.ComboBox4, [Database], 2, 0)
    Me.lblPreço4 = Application.WorksheetFunction.VLookup(Me.ComboBox4, [Database], 4, 0)
    Me.lblPreço4.Caption = Format(lblPreço4, "Currency")
End Sub

Private Sub ComboBox5_Change()
   
On Error Resume Next

    Me.lblUnidade5 = Application.WorksheetFunction.VLookup(Me.ComboBox5, [Database], 3, 0)
    Me.lblQuantOrig5 = Application.WorksheetFunction.VLookup(Me.ComboBox5, [Database], 2, 0)
    Me.lblPreço5 = Application.WorksheetFunction.VLookup(Me.ComboBox5, [Database], 4, 0)
    Me.lblPreço5.Caption = Format(lblPreço5, "Currency")
End Sub

Private Sub ComboBox6_Change()
   
On Error Resume Next

    Me.lblUnidade6 = Application.WorksheetFunction.VLookup(Me.ComboBox6, [Database], 3, 0)
    Me.lblQuantOrig6 = Application.WorksheetFunction.VLookup(Me.ComboBox6, [Database], 2, 0)
    Me.lblPreço6 = Application.WorksheetFunction.VLookup(Me.ComboBox6, [Database], 4, 0)
    Me.lblPreço5.Caption = Format(lblPreço5, "Currency")
End Sub

Private Sub ComboBox7_Change()
   
On Error Resume Next
   
    Me.lblUnidade7 = Application.WorksheetFunction.VLookup(Me.ComboBox7, [Database], 3, 0)
    Me.lblQuantOrig7 = Application.WorksheetFunction.VLookup(Me.ComboBox7, [Database], 2, 0)
    Me.lblPreço7 = Application.WorksheetFunction.VLookup(Me.ComboBox7, [Database], 4, 0)
    Me.lblPreço7.Caption = Format(lblPreço7, "Currency")

End Sub

Private Sub ComboBox8_Change()
   
    On Error Resume Next
   
    Me.lblUnidade8 = Application.WorksheetFunction.VLookup(Me.ComboBox8, [Database], 3, 0)
    Me.lblQuantOrig8 = Application.WorksheetFunction.VLookup(Me.ComboBox8, [Database], 2, 0)
    Me.lblPreço8 = Application.WorksheetFunction.VLookup(Me.ComboBox8, [Database], 4, 0)
    Me.lblPreço8.Caption = Format(lblPreço8, "Currency")
End Sub

Private Sub ComboBox9_Change()
   
    On Error Resume Next
   
    Me.lblUnidade9 = Application.WorksheetFunction.VLookup(Me.ComboBox9, [Database], 3, 0)
    Me.lblQuantOrig9 = Application.WorksheetFunction.VLookup(Me.ComboBox9, [Database], 2, 0)
    Me.lblPreço9 = Application.WorksheetFunction.VLookup(Me.ComboBox9, [Database], 4, 0)
    Me.lblPreço9.Caption = Format(lblPreço9, "Currency")
End Sub




Private Sub tbQuantUsada1_Change()


On Error Resume Next

 Me.lblCusto1 = Me.tbQuantUsada1.Value * Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 2, 0)
    Me.lblCusto1.Caption = Format(lblCusto1, "Currency")
   


Set Custo1 = Me.tbQuantUsada1.Value * Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox1, [Database], 2, 0)
   
 Me.lblTotal1 = Custo1.Value
End Sub

Private Sub tbQuantUsada10_Change()
On Error Resume Next

 Me.lblCusto10 = Me.tbQuantUsada10.Value * Application.WorksheetFunction.VLookup(Me.ComboBox10, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox10, [Database], 2, 0)
    Me.lblCusto10.Caption = Format(lblCusto10, "Currency")
End Sub

Private Sub tbQuantUsada11_Change()
On Error Resume Next

 Me.lblCusto11 = Me.tbQuantUsada11.Value * Application.WorksheetFunction.VLookup(Me.ComboBox11, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox11, [Database], 2, 0)
    Me.lblCusto11.Caption = Format(lblCusto11, "Currency")
End Sub

Private Sub tbQuantUsada12_Change()
On Error Resume Next

 Me.lblCusto12 = Me.tbQuantUsada12.Value * Application.WorksheetFunction.VLookup(Me.ComboBox12, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox12, [Database], 2, 0)
    Me.lblCusto12.Caption = Format(lblCusto12, "Currency")
End Sub

Private Sub tbQuantUsada2_Change()

On Error Resume Next

 Me.lblCusto2 = Me.tbQuantUsada2.Value * Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 2, 0)
    Me.lblCusto2.Caption = Format(lblCusto2, "Currency")
   
Set Custo2 = Me.tbQuantUsada2.Value * Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox2, [Database], 2, 0)
 
End Sub


Private Sub tbQuantUsada3_Change()
On Error Resume Next

 Me.lblCusto3 = Me.tbQuantUsada3.Value * Application.WorksheetFunction.VLookup(Me.ComboBox3, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox3, [Database], 2, 0)
    Me.lblCusto3.Caption = Format(lblCusto3, "Currency")
End Sub



Private Sub tbQuantUsada4_Change()
On Error Resume Next

 Me.lblCusto4 = Me.tbQuantUsada4.Value * Application.WorksheetFunction.VLookup(Me.ComboBox4, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox4, [Database], 2, 0)
    Me.lblCusto4.Caption = Format(lblCusto4, "Currency")
End Sub

Private Sub tbQuantUsada5_Change()
On Error Resume Next

 Me.lblCusto5 = Me.tbQuantUsada5.Value * Application.WorksheetFunction.VLookup(Me.ComboBox5, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox5, [Database], 2, 0)
    Me.lblCusto5.Caption = Format(lblCusto5, "Currency")
End Sub

Private Sub tbQuantUsada6_Change()
On Error Resume Next

 Me.lblCusto6 = Me.tbQuantUsada6.Value * Application.WorksheetFunction.VLookup(Me.ComboBox6, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox6, [Database], 2, 0)
    Me.lblCusto6.Caption = Format(lblCusto6, "Currency")
End Sub

Private Sub tbQuantUsada7_Change()
On Error Resume Next

 Me.lblCusto7 = Me.tbQuantUsada7.Value * Application.WorksheetFunction.VLookup(Me.ComboBox7, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox7, [Database], 2, 0)
    Me.lblCusto7.Caption = Format(lblCusto7, "Currency")
End Sub

Private Sub tbQuantUsada8_Change()
On Error Resume Next

 Me.lblCusto8 = Me.tbQuantUsada8.Value * Application.WorksheetFunction.VLookup(Me.ComboBox8, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox8, [Database], 2, 0)
    Me.lblCusto8.Caption = Format(lblCusto8, "Currency")
End Sub

Private Sub tbQuantUsada9_Change()
On Error Resume Next

 Me.lblCusto9 = Me.tbQuantUsada9.Value * Application.WorksheetFunction.VLookup(Me.ComboBox9, [Database], 4, 0) / _
    Application.WorksheetFunction.VLookup(Me.ComboBox9, [Database], 2, 0)
    Me.lblCusto9.Caption = Format(lblCusto9, "Currency")
End Sub

Editing VBA in a number of files efficiently

$
0
0
I have a large number of files that are structurally the same - only the data and the file names are different.
I want to insert some code into all of them.

I don't yet know how to open all the VBA pieces together at one time for editing. Is that possible?
Otherwise all I know how to do is a manual, file by file, process.

Ideas?
Viewing all 49926 articles
Browse latest View live