I have sales per month going down a column and I would like to subtract a corresponding $ amount going across columns. It's hard to explain but I would like a formula that I can populate all of the cells with. Spreadsheet should make it clearer.

I have a userForm (Form1) that contains a persons name that I would like to reference in a separate UserForm (Form2). In the separate UserForm (Form2) I need to reference this persons name many times, so I was wondering if there was a was to declare this name in the separate UserForm (Form2) as a constant. Only thing is that a constant, to the best of my knowledge, must be an expression and not a variable. Mainly, I'm trying to avoid declaring the myName variable in each Sub within Form2, which it will be needed for a ton of Sub's.

Code for Form2: Const myName As String = Form1.txtName.Value

I have a total number of hours I want to subtract from. Example in cell e3 I will have 800 hours. In cell f3 I have the number 2 (to represent 2 workers at 40 hours, so that should total 80). I then want f3 to multiply by 40, then that total subtract from the 800 hours in cell e3. Basically I want to be able to put 2 workers in a cell, have that multiply by 40 and minus from the 800 hours in cell e3. I want that to carry on for cell g3, etc.

is there a way to do this in VBA? I've also read: - Dave Hawley's recommendation of using: Sheet1.UsedRange.SpecialCells(xlCellTypeConstants).ClearContents

from another thread (which is excellent!)

- SHG's recommendation of using a named range, for example:

Range("Inputs").ClearContents

Given my limited knowledge of VBA, how would I now combine the two to write a VBA sub-routine that clears a named range entitled "Entry" on a sheet entitled "Data"? Would the following be the correct syntax: Worksheets("Data").Range("Entry").SpecialCells(xlCellTypeConstants).ClearContents

I have a spreadsheet of clients' body weights each week which goes in a column and to the right of it I have a "diff" which I want to show weight gain/loss.

So for a client with weigh-ins the week of 10/1, 10/8, and 10/15 the columns will be:

10/1(V1)--Diff(W1)--10/8(X1)--Diff(Y1)--10/15(Z1)...and so on.

If I have weigh-ins for each week, no problem. I would just have to: =SUM(X1-V1) to get the change in weight from the week of 10/1 to 10/8. Say the client weighed 200 on 10/1 (V2) and 195 on 10/8 (X2), the difference (or "diff" (Y2)) would be -5.

But let's say the client didn't weigh-in on 10/1. The difference in weight is going to be 195. Or if they weighed-in on 10/1 but didn't on 10/8 it's going to read -200.

So I have two cells (say V2 & X2) that if one of them is blank, I want the "diff" to read "N/A" or at least leave the cell blank.

A B C D Date ReceivedApproved DateDenied DateTurn Time 1/1/14 1/13/14 9

Turntime is calculated with this formula: =IF(A4<>"",IF(COUNT(B3,C3),NETWORKDAYS(A3,IF(B3<>"",B3,C3)),""),"")

What I need is to not count the first day it is received in the calculation for the Turn Time. So in this instance I need the Turn Time to say 8 instead of 9. If I just subtract a 1 then I get an error if the Approved Date or the Denied Date are not filled in yet.

I had a question considering a workbook that I am working on for overtime, a different one than I posted before. On my workbook, I have vacation leave, sick leave, and overtime to figure in. I want to be able to have a choice to choose which you would like to keep at the end of the week. Such as if you were to work 8 on Mon, 8 hours on Tues, 10 hours on Wed, and then take vacation leave on Thur, for 8 hours, and then work 6 hours on friday, I need a way to choose whether to be paid for the overtime and vacation time, or to subtract two hours from my overtime and add it to my regular time, i.e. 40 hours, or subtract two hours from my leave time and add it to my regular time. I know this sounds complicated, it is at least to me.

I was trying to subtract two arrays of data and putting the result in some cells but with no success unfortunately. I'm relatively new to VBA and I'm just starting now to make calculations with arrays so excuse my little knowledge. The arrays that I'm trying to subtract are from row 1 to 250 and m and n variables have the number of the columns. Here is my routine:

I need to convert a cell that has a list of values A1 = 1,2,3. To a range expression {1;2;3}. I want to do this with a formula and not VBA. Example: Cell D1 has the formula = SUMPRODUCT(COUNTIF(C30:C31,A30:A32),B30:B32). I want to put the list range from column C into one cell.

I need an equation that lets me determine whether a cell contains a static constant value (either a string or a number), or an equation that generates a value.

Problem: I have a cell that contains a default equation that generates a default value, depending on a few conditions. The user can overwrite this cell with a constant. In another cell I need to know whether that cell is still the default equation or a new constant value.

I cannot simply test the value of the contents to see if they match my default, because the user may choose to enter that value.

I have added a worksheet to a workbook, a co-worker will populate another worksheet within is workbook. The worksheet the co-work populates is a schedule. On my worksheet I've set a possible units per day value, then pull from the schedule, starting from the top, the order that can be done in this time frame.

My problem is every so often in the schedule she will total the units in a cell (the units for each order are in one column and the total is also in this column, and this has to be this way for others in the plant). My formula checkes the sum of the units in this column, but it includes the cell that has the total units. This is the only cell that has a value in it on this row. I was trying think of some way to check the order number column for a blank, and if it was then subtract the value in the cell that has the units total in it.

I am tryinig to use an if statement but I don't have it correct. If columns E, F, and G are not null I want it to subtract 3 from the Total column. Right now it is subtracting from G.

Sub SubtractPoints() Dim I As Long, subpoint As Long With ActiveSheet subpoint = . Range("h65536").End(xlUp).Row For I = subpoint To 2 Step -1 If Not .Range("E" & I) = "" And Not .Range("F" & I) = "" And Not .Range("G" & I) = "" Then .Range("H" & I) = "=RC[1]-3" End If Next End With End Sub

the way my spreadsheet's set up so far is that each employee should have a goal of, say, 100 for how many people they need to sign up. But they each have specific geographic breakdowns in their turf, some of which might be bigger or smaller than others, but at the end should all add up to 100 for each employee.

It's not super hard to do since I just take a goal of 100, in this example, and multiply it by the percent of population of the area in their overall assignment and give them a goal for that area based on that. So if Philadelphia has 70% of their total population, Upper Darby has 20% of their total population, and Phoenixville has 10% of their total population -- the goals would come out like this:

For some of the employees, that works out perfectly -- but based on the population sizes, the rounding sometimes gets a little off and it could end up like this:

For most employees, it ends up being dead-on 100 -- but there are some whose totals are at 98 or 99 or 101, and I was wondering if there was a way to force it to shave a point off or add a point on somewhere, pending on how close the decimal was when it rounded to make sure that it always ends up exactly on 100. (I'm using 'Data >> Subtotals' to get what's being represented above as "Ryan, Total Goal.")

I am creating on the fly an array (2 columns) in which the one row cell is mathematically derived from its neighbor (A left-hand cell). However, when the mathematically derived product exceeds a value, the row neighbor changes to another constant until its neighbor's product exceeds another value, etc. Can I create such an array without resorting to VBA?

I'm trying to set named range as a constant in VBA, to allow me to recall the same range as an output target in different subs, without having to 'set' it in each module. I have tried to declare it at the top of a module like this...

Public Const tpnb_range = Worksheets(" SQL").Range("tpnbs")

and get a "Compile Error : Constant expression required"

If in Cell A2 I have a function that updates it's number value automtically (i.e. From 5 to 7) and in cell B2 I have a value I wanted subtracted to the value Cell A2 updated by. Is this task possible?

In the I.e example, cell A2 had an updated value by 2, will it be possible to subtract that value in Cell B2 and continue doing so if Cell A2 kept updating?

I have a template with formulas calculating a default value, but still allowing the user to override the cells with direct input.

I want to use conditional formatting to highlight any cells that have been overwritten, but can't find a way for Excel to differentiate between a cell with a formula or an inputted constant.

I realize there is a VBA "isFormula" function, but I don't want to have to use VBA for this.

If I have the following: =SUM(E2:F2) - G2). So lets say that E2 has 50, F2 has 60 which = 110. Now I want to take that 110 and subtract it from what is in G2 and put the result in H2.

I'm decently competent at VBA but no real experience with userforms. I have a very simple 3x2 table:

Type $Amount Cash $xxxxxx Product A $yyyyyy Product B $zzzzzz

I want a simple userform that moves money between the products, ie the user selects a money amount in the form (ex: $1000) and that amount is added from one product and simultaneously subtracted from the other. Note that the amount selected would be subtracted from one product's current balance and added to the existing balance of another product. No new money is coming into the system.

I have cell C5 value set as 5*B5+3. Now, using vba,I would like to adjust the value of B5 (basically find it), so that the value of C5 is let's say 8.

In this easy example, one can find rapidly the correct value of B5 to be 1.

What I've tried is the following code:

Private Sub CommandButton1_Click()

Range("B5").Value = -5 Do Range("B5").Value = Range("B5").Value + 1 Loop Until Range("C5").Value = 8 End Sub

So, I am setting the initial guess for cell B5 and then increasing it by 1. However, if I set the increment to 0.5 instead of 1, program goes crazy and loop doesn't close.

What changes should I introduce to this code, so that even if the increment is 0.001 everything will work.

I keep getting an application error, in debugging the underlined line is the source.

Sub blank() Dim c As Range For Each c In Range("C1:C100") If IsEmpty(c) = True Then c = Range("c").Offset(0, 1) - Range("c").Offset(0, -1) End If Next End Sub

Is it possible to use a contstant array in Excel VBA? I have tried several differnt ways to declare it, but the VBA editor keeps yelling at me. The following did not work:

So I have module1 -> Sub Macro1() module2 -> Sub Macro2() module3 -> Sub Macro3() module4 -> Sub Macro4()

I have declared

Option Explicit

Dim mdNextTime1 As Double Dim myEnter As Integer 'Dim myK1 As Integer 'Dim myK2 As Integer 'Dim myK3 As Integer Dim myK4 As Integer Const myC As Integer = 82 Dim Lastrow As Integer Dim myActualRow As Integer