I need to allocate an existing subroutine (its code below) to a new button I'd like to add to my sheet. Two questions arise: to use "form control" or "activeX"?, also should I redfine the first line of the code?
I'm having trouble calling a subroutine from a command button. It's puzzling because I've set up buttons before and didn't have this trouble.
Here is my button Private Sub EPConversionButton1_Click(ByVal target As Range) Convert_Hrs_EP target End Sub And here is the subroutine.
Sub Convert_Hrs_EP(target As Range) End Sub There's nothing there yet, but I keep getting error messages regarding the transfer from the button code to the subroutine.
The message is: Procedure declaration does not match description of event or procedure having the same name. The Help file says this means that my procedure has the same name as an event, but does not have the same signature. But it's not so.
I have inherited support for the an Excel 'program' that seems to be fairly unstable. I am currently having problems with the following code in a subroutine (executed when the user presses a command button):
With ActiveSheet.PageSetup .PrintTitleRows = "$1:$7" .PrintTitleColumns = "" .PrintArea = ActiveSheet.UsedRange End With
Sometimes it works and sometimes I get the following error: Run-time error '1004' Unable to set the PrintArea property of the PageSetup class.
… on the .PrintArea = ActiveSheet.UsedRange
I am having a hard time figuring out what is causing its wishy-washiness. Running the following code (launched from worksheet named 'consumer' with a command button):
My Vlookup result may relate to a number of occurances of the same source product code. I want to allocate the result so that the last occurance gets the balance. See attached file.
I allocate result of formula FORMULA R1C1 into the active cells,,,AND NOW I wan to allocate it into a variable x or y (I dont want that the result appears in the spreadsheet, just into a variable to work the code!)
The number of transactions is scaled down to provide this example.
Rebate scheme (Cum Sales = Cumulative sales) based on the total turnover of a group of customers.
Cum Sales....Rate....Sales Band...Rebate 20,000........1.0%.......20,000........200 35,000........2.0%.......15,000........300 45,000........2.5%.........3,400.........85 ...................Total......38,400.......585 average rebate 1.5%
I would like to correctly allocate the £585 rebate across the individual customers who have generated the turnover i.e. NOT by using the simple 1.5%.
Clearly the large sales value customers will have earned a higher % rebate than the lower sales value customers - but how to calculate?
I am trying to create a Excel file for my job. I work in a warehouse where I have many different orders all of which are made up of various different numbers of items and priorities. For example:
Order 1 = 45 items, Priority 1 Order 2 = 78 items, Priority 1 Order 3 = 48 items, Priority 2 Order 4 = 34 items, Priority 3
The total number of items is divided by the number of staff to give each staff member a total for the evening.
I plan to have a list of these orders in the excel file.
What I would then like to do is to have each staff member allocated orders so that the their total is reached. The sheet would automatically allocate orders to each person from the list of orders so that based on priority first then by the largest number of items to the smallest.
I think this should be a fairly simple sheet to create and I have a view of creating an application for it if I can get it working.
I want to allocate the Quantities which is available in DC based on Sales, Store OH and In Multiples of Pallet Rounding (PR).
For Eg. If I have 200 Qtys in DC, Excel should allocate these 200 Qty's in multiples of PR to highest selling stores and also consider the store On Hand.
I'm trying to design a spreadsheet to allocate an amount to different bands.
For example - I have the figure 1750.
Band 1 : 0-500 (1) Band 2 : 501-1000 (0.8) Band 3 : 1001-1500 (0.6) Band 4 : 1501-2000 (0.4)
Each unit in each band has a value (in brackets). So as you can see, the value of a full Band 1 would be 500. But the next band is only worth 400 when full, and Band 3 is only worth 300. I want band 1 to fill up first, then band 2, then band 3, then finally band 4.
I would like to be able to allocate the figure 1750 to all the bands automatically - starting with band 1, then 2, then 3, then 4.
Assign numerical values to the letters G, A, R each having the values of 3, 2 and 1 respectively and then take an average of their values. Please be aware that in some cells there may be no letter.
So in a 5 cell range the values could be:
blank, G, A, R, blank which equates to a result of 2 for an average, (3+2+1)/3 (the two blank cells are discounted).
On Sheet1 I have ListBox1 referencing data from Sheet2 for the ListFillRange property. The Listbox is a control box added on to the worksheet.
I wish to have a VBA Subroutine that defines the ListFillRange dynamically according to the size of the source data range. ie. Sometimes the range is AH3:AL300, othertimes the range could be AH3:AL200 etc. The last row of data needs to be the last selection in the Listbox.
The range looks like: 1 10:00 blah 2 10:05 moreblah etc
Attached is a spreadsheet wherein I'm trying to extrapolate project costs across various months based on working days in a month subject to start and end dates of the project. Need an accurate formula to spread the cost.
VBA jumps out of my called subroutine which is stored in a Module halfway.
When I call the SortLec() sub, it runs until y1 = Application.Match(MC & "-" & CI, rng, 0), and then it just jumps back to the SUB commandbutton1_click() IF statement. Why is it that VBA skips the rest of the code from my sub?
Option Explicit
Private Sub CommandButton1_Click() Dim i As Integer Dim numofrows As Integer Dim workbook_directory As String Dim file_name1 As String
in writing a subroutine that needs to ask the user
1) tax file number 2) Income 3) tax withheld
It then needs to use a function that i already made called 'incometax' that calculates 'taxpayable' and use that to calculate taxreturn (difference between 'taxpayable' and 'taxwithheld').
I then need it to output like this in a message box
Estimate for tax file number: ..... Created on ...... Total income: ...... Tax witheld: ....... Tax payable: ......Tax return: .......
My code passes a string created by a function to procedure. It all works great, but i need to add something so that if the string = false then sub doesn't run. What's the best way to do that. Here is some of the
1. Can a Subroutine be called from within a user-defined Public Function? How?
2. Is there a difference between calling a subroutine with a 'Call Sub_Name' statement, vs. calling the subroutine with an 'Application.Run'(?? or similar) statement?
I have a short subroutine to delete a row in a second worksheet (SUMMARY EXPENSES) if one is deleted in the main worksheet (AS CODES) as per below:
[Code] .......
In theory the row deletion should only be triggered IF dynamiccounter is smaller than staticcounter, but the fact is anything whatsoever triggers the row deletion. If I type text into a cell a row gets deleted. If I copy a cell, a row gets deleted. It works great at deleting the line, but I suspect it has nothing to do with the counters I set up and the reassigning of the counter value towards the end of the If statement.
I have a small sub routine below I would like to make a slight modification to. The routine currently references formatting relative to the Offset statement in bold below. Instead, I would like the formatting to come from a cell address listed in a cell just to the left of the cursor when the statement is encountered.
I'm trying to put some visual basic out on the network drive at work so I created a book and called it Macro.xls. I then saved the code within that book and saved it out on my network. I'm now trying to run that code by calling the sub and don't know how to do that.