how can i do the following using VBA
making each cell in column A added to each cell in column B and the result will be in the column C
for example
c1=A1+B1
c2=A2+B2
c3=A3+B3
... etc
i know i can do that simply without vba code but I just want to use this method to implement more complex formulas .
I have a macro which sorts data within a cell. This is working perfectly fine but the only problem with this is that it works only for a single which is selected. How can I apply this macro to range of cells I select using a mouse.
I was messing around with some Macros, as an issue came up where clients were pasting over Data Validated cells (thus removing the validation). Somehow though, the feature where you can select a cell, then pull the active cell down through the column (and then can copy, fill series, etc)has become disabled. I deleted all the macros, and turned them off in the Trust Center, but when I click on a cell the box and plus sign still won't display for me to pull the cell down the column.
have a code for restricting printing until some cells are filled; however the code is been applied to all the file. I need to apply it to one one sheet. Thanks for your help.....
Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet If Application.WorksheetFunction.CountA(.Range("A11:K11"), ("A13:K13"), ("A16:K16"), ("A19:I19"), ("J18:K18"), ("A22:K22"), ("A25:K25"), ("B63:B64")) < 8 Then MsgBox "Please Complete Information" Cancel = True Else 'Allow printing End If End With End Sub
Is there a way to create a macro to color code a cell based on the value in a cell, and then look up a value in a table, then color code it based on where it fits into the table?
I have a table of values for about 30 projects. In column g - there is a CPI value (see bold column)
Example: Project ID Name Program PMT SI ID AC Milestone TCP Level [Code] ......
Here is the table:
I have to color code a cell, base on the CPI and how it fits into the table below. So if the current Milestone is M2 or M3 and the CPI calculated is .14 the cell would be colored RED, if the CPI number is 2.01 for M2-M3 I would want cell to be colored Turquiose. If we were at Milestone M6 and the CPI was 2.01, it would be colored blue. If the CPI was .75 at Milestone M5, it would be colored Green
I have a code that opens a workbook and saves it under one file name and then saves it under 2 different file names, but it keeps on saving them as password protected and I can't work out why. Would it be something to do with the code or something else? The following is the code I am using:
I have a number of different modules. Each module does something similar, but different to a specific workbook. Instead of running the macro(s) individually is it possible to have a parent-class that calls on each module, and further to have each module *know* which worksheet it should apply to?
Example below:
Code: Sub Cost_Center_Information_File() 'What it does: applied to a worksheet (there are about 15 worksheets in the workbook) it 'will do some formatting manipulations.
I have 10 ranges that if the value in a cell falls into one of those ranges, a calculation needs to occur. I think I need to use a macro which i have set up to run off a button click, with a do loop in it, but not sure how to get the loop to move down the range?
for example:
Cell Reference(s):
D 1 250 2 700
Range:
A B C 1 0 150 75 2 150.01 300 125 3 etc.. etc.. etc..
Im using a commandbutton to apply a discount to a range of cells. I want to give the user two options based on either 18 months or 24 months.
So I was thinking somthing like, when the command button is used have a msg box asking them which term 18 or 24 than apply the discount to Range H25:H34.
I want to set the discount % to Range P20 for 18 months and P21 for 24 months.
I was able to get my four conditional statements in VBA to work. This covers one complete row of data (week), but I need it to cover an entire year. Rather than cut and pasting 365 times (and some UGLY code at that), I have been trying to figure out how to add a loop or something to cover a range of different rows. Basically Columns B though V are good for row 21. Now every 14th row I need this routine to work for (B35:V35, B49:V49, etc) for 52 weeks. I was playing around with the idea of two for statements taht would count shifts (21 = 7 * 3) and weeks (52). Then step the rows at 14 and the columns at 1 (Rows = Rows + 14) for 52 iterations. I'm sure there is a better way to distribute this routine.
Private Sub Worksheet_Change(ByVal Target As Range) Dim changeRange As Range
Select Case Mid(Target.Address, 2, 1) 'Column Letter Case "B" Set changeRange = Range("B21") Case "C" Set changeRange = Range("C21") Case "D" Set changeRange = Range("D21") Case "E" Set changeRange = Range("E21")
I am trying to update a project tracking sheet at work and I am having trouble. I have a list of construction projects (approx 130) along with details on the project, one detail being % completed. I am trying to create a summary of the projects at the bottom of the page, showing the total value of all projects, according to the % completed.
<10% is ANTICIPATED = 10% is AWARDED >10% <90% is IN PROGRESS >90% is COMPLETED
I use the If - Then statement in VBA to determine a condition which works perfectly fine for the particular cell I reference to, but i need it to apply to all the cells i.e. cells A1:A10?
Sub MACRO1()
If Range("A1") = "PAYE" Then Range("B1").Formula = "=C2 * .128" End If
If Range("A1") = "LTD" Then Range("B1").Formula = "=(C2 - 100)* .128" End If
I need to input a formula that will produce a "yes / no" result if a "0" value appears consecutively six or more times.
Using the date below (ranges A1:Q1, A2:Q2 and A3:Q3), I need cell R1 to read "yes", as there are 7 consecutive "0" values. Cells, R2 and R3, however, need to read "no" as there are less than six consecutive "0" values in rows 2 and 3 respectively.
I am using two separate workbooks. I am tranferring dates into a new spreadsheet to track projects dates for milestones.
The formula I am using is this: =IF('[BBBBB Dates as of 9-9-13.xlsx]Sheet1'!$CQ$4="", VLOOKUP(W54, '[BBBBB Dates as of 9-9-13.xlsx]Sheet1'!$1:$1048576, 94, FALSE), VLOOKUP(W54, '[BBBBB Dates as of 9-9-13.xlsx]Sheet1'!$1:$1048576, 95, FALSE)).
I would like the cell to turn green if the last part of the formula is true and stay clear if the first part of the formula is true.
I also need to add color beyond just that. I was attempting to apply conditional formatting but am a bit stumped. I want the green to be maintained regardless of other formatting. I would also like to apply to cells that are not color coded green:
Red - if the date is overdue Yellow - if the date is within 7 days Otherwise, leave the cell color as clear
Is this possible with conditional formatting? I am not at all proficient in VBA...
I have thousands of path names in a spreadsheet that were converted to hyperlinks, but my client wants to see only the filename in the hyperlink, not the whole path.
I created the hyperlinks by applying the following to the column containing the file paths: ....
For simplicity, let's assume I have three columns, "Company," "Policy," and "Balance."
Example: Company A Life $1 Company A Med $2 Company A Dent $3 Company A Disab $4 Company B Life $9 Company B Med $5 Company B Dent $7 Company B Disab $2
According to my post preview, the columns are running together, but I do have it arranged in three distinct columns. What I want to do is program a macro to do the following:
Every time the name of the company changes, I want Excel to insert two rows after the last of the group, and have a summation of the "Balance" column in the first inserted row.
This is what it should look like:
Company A Life $1 Company A Med $2 Company A Dent $3 Company A Disab $4 $10 <- (this should be directly under the $4, but I'm not good with forum languages)
Company B Life $9 Company B Med $5 Company B Dent $7 Company B Disab $2 $23 <- (same with this - should be directly under the $4)
Supposing you would like to find the median of numbers in column D, but only for rows that have the word "Jones" in column A? Is there a way to do this? Obviously I know I could do a sort and simply specify the range myself, but we're dealing with nearly 2000 rows and a LOT of different values in column A
It occurs to me that it would be even better if I could ask excel, in effect, to identify every separate text string in column a and then find the median of the corresponding numbers in column D. In other words I wouldn't have to type any strings from column A at all.
If you have a range of cells with values in them (Q2:AZ2), you can use conditional formatting to identify the top x% of the group and it would essentially treat each cell in comparison to the group. I need to identify if a cell in the group is greater than 3*Stdev(Q2:AZ2). Do I have to create conditional formatting for each individual cell or is there a way to apply a function to the group that would recognize each cell the same way that the canned conditional formatting rules work?
how do I apply a formula I entered into one cell to all the cells in that column, without going through the tedious process of typing the formula in again in each cell ? I've done it before but don't remember how.
I have an Excel 2007 Workbook which is refreshed by a Web Query. I have dynamic named range defined as "Manager" which I've confirmed is correctly identified. This range includes only one column and is formatted as text.
When I try to reference this range in my conditional formatting "refers to" formula, all cells are recognized as blank even though the range clearly contains many cells that are not. For example, there are 90 records containing the initials "PD". If I use the formula =Manager="PD" in my conditional formatting, nothing changes. If I change it to =Manager="" then ALL records are formatted, including those that are not blank.
Stranger still, if I enter the formula =COUNTIF(Manager,"PD") into and empty cell in my worksheet those 90 records are counted correctly. Which leads me to believe it isn't about the data. Conversely, =COUNTIF(Manager,"") returns the correct count of only cells that are, in fact, blank.
I've tried using the OFFSET formula defining my range in place of the name itself for my conditional format formula to no avail.
I am trying to write a macro which will autofill specific columns. The macro will set the range from the start of my autofill to the end of my autofill as a constant range.
The problem I need to get around is the end of my range can always change each time I run the macro. For instance, the first time I run the macro I may only need to autofill from row 4 to row 15. The next time, I may only need to autofill from row 4 to 23 (because of user updates). How can I make the end of my range not be a constant address but variable?
I have a whole ton of *.dbf files (98 to be exact), that are from ArcGIS shapefiles. These date1_date2.dbf files have point names, and values, as shown below.
NAMERASTERVALU Point 1-9999.00000000 Point 2-9999.00000000 Point 3-9999.00000000 Point 4-4.93072701 Point 5-8.90071201
I'm trying to figure out how to transpose each of the dbf files and save them as a text file (tab deliminated). My original plan involved saving them all as text files, then using a convoluted Unix script (I'm what you call a "dirty programmer") to transpose them and then combine them all into a single file. Since there are so many files (and I plan to do this in the future as well), I thought if I could at least automate the text file creation, I'd be ahead of the game. Even better would be a macro that will transpose the data for EACH file, then create a 99 (98 files + header row) row, 5 column text file. Creating the text files (1 text file for each dbf file) automatically .
All the *.dbf files will have exactly the same # rows/columns (2 columns, 6 rows)
This is what I've tried so far. 1)open one of the dbf files in Excel 2)record my marco (using the Personal Macro Workbook option - so it will be available in any workbook) 2a) transpose data (and paste it right below the original data so that the new data is in rows 7 and 8 of the same file) 2b) save as text file (tab deliminated) 2c) stop recording, and end up with this:
NAMERASTERVALU Point 1-9999.00000000 Point 2-9999.00000000 Point 3-9999.00000000 Point 4-4.93072701 Point 5-8.90071201 NAMEPoint 1Point 2Point 3Point 4Point 5 RASTERVALU-9999.00000000-9999.00000000-9999.00000000-4.93072701-8.90071201
So now I want to apply the macro I just created to all open workbooks (after I bring in all the bdf files), but the macro isn't listed when I click the "view macros" button. All I want to do is apply the steps I recorded in the macro to all open workbooks.
I am writing some code to help speed up data input into Excel. I take the info from the user through a form. Before pasting the data into a spreadsheet, I need to check that there is no data there already.
How can I check that the sum of range of cells in excel, as specified by the user in the form, is Zero?
I want to do this in the code rather than enter another cell in excel and sum it there