Excel 2007 :: VBA - Add New Rows If A Condition Is Met
Feb 16, 2014
how can I write a routine to add rows in one Sheet if a condition which involves a different Sheet is met (excel 2007).
In Sheet 1 is a list of ("liquid") names (cells C4:C26) which will need to be expanded should the IF condition be satisfied. In row 27 I have a subtotal (whihc is using data from columns D onwards), and from row 29 down cells are not empty.
The condition I want to verify is in Sheet 4-column I, where it is reported whether a name is classified as "liquid" or "illiquid". If the number of "liquid" names in sheet4-column I is more than the number of names in Sheet1-C4:C26 I would like to add as many rows as the difference between the two lists. Also I would like to make sure that the subtotals that I have in row 27 (and that will be shifted down when new rows are added) will also inlcude the data in the new rows (the subtotal is taking data from columns D onwards).
Should the code need to inlcude the name of the tabs, Sheet 1 is called Summary and Sheet 4 CDS Data.
I am working on a schedule worksheet, the days are the columns and the staff member names go down the rows. I want to create a new cell value based on a condition on each row. I have been successful working with one row but how to efficiently do the same for each row.? I'm working with Excel 2010.
I have a macro that exports a row (or rows) to destination sheet ("Amber") based on criteria in Column K. Once exported I return to the source sheet ("Register") and the row that had the data that I wanted exported has exported the info but the row just sits where it was and appears to only 'clear the contents'. The macro I use is:
Sub Extract_FW_Rows() Set ws = ActiveSheet endrow = ws.Cells(65000, 1).End(xlUp).Row For i = endrow To 1 Step -1
I set up the macro on Excel 2002 in work as thats what we have....however when I input the same code into my home laptop working Excel 2007, all works perfectly i.e. it cuts the data to destination sheet, goes back to source sheet and the rows have moved up accordingly - I do realise that the action taken is a row removal i.e. I had 1000 rows, macro executes, I now have 999 rows in the source sheet.
What I would like is the same result in 2002 as I get in 2007.
I have files that have thousands of rows in them with company names. The rows contain the company name plus lots of other info. I'd like to be able to create files or sheets with the company name as the file or sheet name with the respective rows contained within it. Make sense?
Original file or sheet Date Company Info1 Info2 Jul Sams Expense Desk Jan Freds Expense Doughnuts Jun Sams Deposit Return Feb Sams Expense Food Dec Freds Expense TV
Sheet or File Sams Date Company Info1 Info2 Jul Sams Expense Desk Jun Sams Deposit Return Feb Sams Expense Food
Sheet or File Freds Date Company Info1 Info2 Jan Freds Expense Doughnuts Dec Freds Expense TV
- 12 unique values in column 6 which represent states within the country. - 7 unique values in column 25 which represent the types of services. - 5 unique values in column 27 which represent the days for doing the services.
I also have a user form that contains CheckBoxes equivalent to all above unique values, and I want the CheckBoxes to do the duty of a filter, whereby after selecting the needed CheckBoxes and clicking on a seperate botton "creating report", I want to show on the spread sheet only the rows of the values being checked and all other rows which don't contain the needed values should be either hidden or deleted.
Excel 2007 holds data of mine in a "format as table" Table. I want to rank the values in one column. Normally I want to do that by ranking the value in the current row against all the remaining values in that column. That is easy.
I got stuck today when I wanted to rank the value of the field in the current row with only a subset of the values in the column. I want to rank the current against the half-dozen or so records that have "A" in an adjacent column, and rank values having "B" in that other column against only the other values a "B" and so forth.
It would be best for all this to be done in formulas in the table rather than a clever use of a pivot or other? But really, I may be open to different approach than I was trying for if I can use successfully!
Is there a way to select completely empty rows in Excel 2007 (Win 7)? I have found directions for highlighting empty cells (f5, Special, Blanks...), but sometimes the cells selected will be in rows with other filled cells in them so that doesn't really do what I need.
I am wanting to find rows that with unique values in the first column, and then take those rows and display them in a more readable format. The section titled input is an example of information that would be pulled from a query into Excel. The Desired Output section is how I would like the info to be displayed. If this is possible without VBA then that is even better.
I have a long (about 180 000 rows) list of part numbers, descriptions, prices and quantities. There are many duplicate part numbers. I need to go through and find the duplicates, add all their quantities into one cell and delete the remaining duplicates. I have used conditional formatting to find the duplicates easier but cannot use the remove duplicates button as it will delete the whole row and I need the quantity information in each row.
Any formula or macro I can set up to search the part number column (F) for duplicates and add the figures in the quantity column (J) and THEN delete the duplicate part number rows?
Maybe I need to put the new combined information in another sheet?
My knowledge of Excel 2007 is minimal, from formatting individual cells, to creating column totals. I've used it for years in my household budgets. I have an attendance form which is about 3 pages long; currently, it's separated at page breaks, with column totals at the bottom of each 'page'. This is easy because the Row #s are infinite, right? Lately there have been regular adjustments, and I believe the project might be less cumbersome if it were spread out on separate sheets, but how to bring the rows of column totals to cumulative totals on the last sheet.
I'm using this code to find values of "FEP MHS" or "LSD MHS" in column S and if column S containes either of these values it deletes the entire row from the spreadsheet. I need this to work on a spreadsheet that runs on a daily basis and each day it contains a different number of rows. I have used this code to successfully delete most rows that contain these values in Column S but for some reason it does not delete all the rows, typically leaving 6 - 7 rows that contain these values. I'm using Excel 2007 I need code that finds the last row used and deletes the entire row if these values are present.
Dim CelRSLHMHSD As Range, RngRSLHMHSD As Range, iRSLHMHSD As Long Set RngRSLHMHSD = Columns("S").SpecialCells(xlConstants, xlTextValues) For iRSLHMHSD = RngRSLHMHSD.Count To 1 Step -1 If RngRSLHMHSD(iRSLHMHSD).Value = "FEP MHS" _ Or RngRSLHMHSD(iRSLHMHSD).Value = "LSD MHS" _ Then RngRSLHMHSD(iRSLHMHSD).EntireRow.Delete Next iRSLHMHSD
I am still new to this, and I pulled this code off of another site.
Background: - Using Excel VBA, 2007 - I have a sheet that has a name in B6, has 4 blank spaces beneath, and then another name, 4 blank spaces, etc. - I wrote a code to fill each of these 4 blank spaces with the value at the top of each - The code works, but it won't fill the 4 spaces at the bottom of the column.
What is needed: -how I can adjust to code below to fill in the 4 spaces beneath the last value in the column?
Sub FillBlanks() Dim rRange1 As Range, rRange2 As Range Dim iReply As Integer
What im needing is something that will duplicate each row based on Column F as shown below... However I also need the duplicate row numbers added to Column G and then the original row deleted... I will try and show you an example of the input/output i would like to achieve: (also the first row can be ignored it will all be headers)
I am trying to develop a compliance report with Excel 2007) based upon a simple pass/fail criteria. The subtotals must be tracked both by Device (column) and by Requirement (row). There are macros (not included in the attached sample) that hides both columns and rows. I successfully found an example which I modified to correctly calculates data for a column when rows are hidden (see GOOD function below). However, I'm totally clueless on how to calculate data by row when columns are hidden (see BAD function below). What I'm trying to figure out is highlighted in red in the attached spreadsheet.
BAD (returns 0 and includes a circular reference) =SUMPRODUCT(SUBTOTAL(103,OFFSET($B2:$F2,,COLUMN($B2:$F2)-MIN(COLUMN($B2:$F2)),1))*($B2:$F2="Pass"))
I am trying to reformat the attached doc into one single column, It's a race listing of overseas marathons and I need it to look like this
Event Name Event Date City Country Entry fee Website
in date order, one event after the other in a single column so I can flow it into a word doc ready to be designed. I need to apply in Excel (I am using 2007) to get this doc into the required format?!!
In Worksheet 1 Column AQ contains a Cost Centre number which I would like to extract the parent description of in Column BI of the same Worksheet and then the child description into Column BJ. Worksheet 1 currently has 16000+ rows and grows daily.The location of the Cost Centre in Worksheets 2-4 is contained in Column A and the Parent Description in Column W and the Child Description in Column Y.I am currently using this INDEX MATCH formula to search all worksheets but as you can imagine it's tediously slow and needless to say sometimes not reporting/updating the values correctly likely because it's frozen.
=VLOOKUP(AQ2,INDIRECT("'"&INDEX(Sheet1!$A$1:$A$4,MATCH(TRUE, COUNTIF(INDIRECT("'"&Sheet1!$A$1:$A$4&"'!A2:A63355"),AQ2)>0,0))&"'!A2:W63355"),23,0) this looks up Cost Centre in Worksheet 1 Column AQ and returns the results from Column W in Worksheets 2-4 to Worksheet 1 Column BI
I'm working in Excel 2007 and need to move data from multiple rows to a single row if the ID matches.Below is sample data I would be working with. I want to move data from columns F-U to the right of the original data in the row above it. I would also like to delete the rows that had data moved.
GIDSurnameNameEmployee Number OriginalDate of birthGranting ARE Employing ARECountry Employing ARECHCM Supplier IDVehicle Investmt. shares / Awards at termination dateMatching Shares at termination dateTermination
I want to count the number of duplicate rows where the exact text in columns A and B match. An example is as follows, where column C would be the desired result. Note that there are hundreds of different text values of column A and hundreds of column B, I just simplified the example.
This works fine on small data sets, but on larger data sets it gives me the error message, "Excel cannot complete this task with available resources". This happens even when I try to do the deletion manually (without VBA code). Clearly, the code itself is not the problem.
My document has about 250,000 rows and 2,500 columns. While this is big, it is significantly smaller than Excel's documented limit of 1,048,576 rows and 16,384 columns.
I am using Excel 2007. My computer has 2GB of RAM but even when I try it on a computer which has 8GB of RAM it gives me the same error. If I "ClearContents" instead of "Delete" it works fine. For my purposes, however, deletion is entirely necessary.
I am trying to conditionally format rows based on the first cell in each row. I had this working in a previous worksheet and have gone through several examples based on answers in other threads but do not for the life of me know what I am doing wrong. I am using the conditional formating rules on the ribbon menu.
I have a range A3-W100 pre-formatted with generic data and formulae. Column A has no data. I want the text to change color for that row if the cell in column A is populated. The background and text are set to black to appear unpopulated.
When an item number is entered in column A3, the text color in row 3 changes to white. I can get this to work on one row but if I extend it through the range, all rows change. I want them only to change if the respective A cell is populated.
I am using Formula is =A3>"" Format is Yellow, Applies to =$A$3:$V$100 Stop if True is unchecked
I need to transpose data from Column A to Row 2 and down.
The data in column A is in sections of 19 rows and then a blank cell and another 19 rows of data contimuously, It is a dynamic range and can contain many thousands of Rows.
The data needs to be transposed from Column A to row 2 (row 1 has the head line for each column) so the 19 lines of data is now spread accross 19 columns in row 2 and the next section from column A is spread accross the 19 columns in row 3 and so on.
My data looks similar to the below. (Test Number 0001 starts in A1)