Macro For Spreadsheets With Different Number Of Rows And Constant Number Of Columns?
Mar 1, 2014
I work on a daily basis with spreadsheets in excel. The number of columns is the same, but every single spreadsheet has a different number of rows. I recorded this macro in a table with 1196 rows and I would like to use this macro also in other tables with a different number of rows.
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.")
In my Macro , i add a worksheet and depending on certain conditions i decide whether to populate it or not.
At a later point of time i am checking if the newly created worksheet is empty or not using the following check :
If ActiveWorkbook.Worksheets(ISheet).UsedRange.Rows.count <> 0 Then
Now what i have noticed is that even in cases where the "ISheet" is empty the above condition evaluates to true for the first attempt. I cannot understand why ?
let me know if the query is ambiguous and i will post the code snippet
I have a spreadsheet which contains data needing to be re-formatted into a suitable format for my database. So far I have been doing this by hand, but want to make it quicker as I have over 2000 lines to sort out. I am trying to write a macro that determines whether there is data in the column next to the active one (D2), and if there is counts how many columns there is data in. Once it has done this it needs to insert the same number of rows as there are columns, then copy the column data and transpose it into the empty rows. My macro seems to work at first, but it exits after around the 4th row, but I can't work out why.
Sub split_For_Database() Dim No_Of_Cells As Integer Dim Start_Cell As Range Dim Cell As Range Dim LastRow As Range Dim i As Integer Dim lRows As Long Set LastRow = Range("C65536").End(xlUp) i = 0 Set Start_Cell = Range("C2") Set Cell = Start_Cell Do While Start_Cell.Address <= LastRow.Address Do While Cell.Offset(0, 1) > 0 i = i + 1 Set Cell = Cell.Offset(0, 1) Loop...................................
I would love to be able to limit the number of rows in a specific sheet so that I can quickly carry formulas to the bottom of a worksheet without carrying them to row 1,048,576. I'm aware of options to hide rows and/or to limit the scrolling with the "view code" option on the worksheet tab; however, I'm mainly worried about worksheet performance. When I carry a formula down, I don't want to see a spinning blue circle run for minutes at a time, and I'm hoping to avoid the same spinning circle when I undo my formula. Is there any way to actually limit the number of rows, or is there any other limitation I could put in that would increase worksheet performance?
I would like to search across a number of rows in a worksheet and then match against two columns.
e.g.
Column B Column C
test 10
I would like the function to match against all rows that match against "test" in Column B and then work out which cell in Column C has the highest value
I'm trying to create a macro that transposes data from columns to rows.
My source data is laid out so Column A and B contain item identifiers, and then the header for Column C to Column S contain dates (March, April, May, etc) and the row data below contains quantities for each month. This is on Sheet1.
I need my end data (on Sheet2) to have the item detail in Column A and B, the quantity in Column C and the Date in Column D. If there is a date that has no quantity then it should be skipped.
Sample Source Data (Pipes added for clarity, they aren't in the actual data)
Part |Description |June 4 |June 11 |June 18 A | PartA | 5 | | 12 (Please note June 11 has no quantity)
Sample Destination Data:
A | Part A | 5 | June 4 A | Part A | 12| June 18
Below is the start of the code, obviously I have a ways to go before it's fully functional but hopefully you get the idea how I'm trying to attempt this. Where I'm having issues right now is referencing columns by number. Is there a way to do this so I can do Column = Column + 1 to advance columns to the right? Or any better way to address this all together?
HTML Code: Sub ConvertToRows() Dim ReviewRow, ReviewRowEnd, PasteRow, ColumnNumber As Integer ReviewRow = 2
I have a sheet with a company name in column A, and a list of comma separated values in column B. I can easily convert column B to multiple columns with the Text to Columns function, but then I'd like to insert each individual value in a new row in column B.
So, at the moment I have data that looks like this:
Company A Value 1, Value 2, Value 3, Value 4, Value 5
I have searched the forum and the 12 pages of results that had the words conditional clumns, but could not find the answer. I am new here so I don't want to ask a question that has been asnwered before. If I missed it I apologize.
I would like to create a spreadsheet that would "automatically" create the proper number of coumns or rows to satisfy a certain set of data. This may be better explained by way of example.
I do financial analysis of real estate. This real estate is say 100 lots today and these lots are going to sell out evenly over a 10 quarter period, or 10 sales per quarter. Simple enough to set up and show the proper cash flow. But lets say I wanted to chnage the sell out period to 8 quarters. Today I would have to manually delete the last two columns. Further let's say I want to run an analysis that has a sell out over 13 quarters. Then I need to add back in the proper number of columns and make sure I correctly copy over the formulas etc.
I'd like a way to have the spreadsheet automatically determine the proper number of columns (or rows) based on a formula that is part of the input data.
I have several columns in an excel sheet which contain values (eg. Names). The entered names can be unique or already exist in the column. I need to find out (using a function or macro) how many different names were entered. Duplicates shshould be ignored in the count.
I have a spreadsheet which is to record quality checks on work carried out by staff. The spreadsheet has a customer reference number in column B and a Staff reference number in column C.
I can carry out a number of checks on a member of staff on one transaction, so for instance, I could carry 3 checks on one customer number, which would result in the staff ref number being enetered 3 times (there is 1 check per row).
I need a formula to count the number of checks I carry out on each member of staff. My problem is that although 3 checks could be completed on someone, if it is on the same customer NO, it only counts as 1 check. In effect, I need a formula to count the number of staff ref numbers which have a unique customer number eneterd in the adjacent column.
All the cust numbers are unique so would I be able to use a wildcard?
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.
I have a range of data and need to summarize some of the data. In the table below is an example of the data. I would like to have a single formula where I can count the number of rows where the end date - start date is < 14 days. I would prefer not to add an additional column for the datediff value. Is there a way to do this with either arrays or named ranges?
Name Start End Other data Verizon 1/10/2010 1/25/2010 AT&T 3/2/2010 4/14/2010
I need to find data in columns B and C and add the figures from column F, which drop down one line. I have written the following formula which is giving me far higher figures than I should be getting
I have a 2010 Excel spreadsheet where I have a macro set up to print the page. What I need it to do though is to increase a number in a cell and display it each time I print the page.
I want to create a macro that will automatrically number cells in the same column. Here is the hard part. I will never start with the same number and the range nor the increment between numbers will be the same. I will start in the same cell. And the number must look like 125+45.65
I would like to create a vba script when ran an input.box comes up and asks you to "enter number you want to start numbering from" and when the number is entered in the input box. e.g "7654", excel starts numbering each cell in column A from 7654 until there is an empty cell in column B.
What If we had to replace any number.. Lets say, if we had to seperate NUMBER TEXT NUMBER in different combinations.... B2 contains values like these then
TOM CRUISE 12 TOM 5879 CRUISE TOM CRUISE 123456789 123456789 TOM CRUISE 123 TOM CRUISE 456
[ = SUBSTITUTE(B2,"1234567890","") ]
I am at my wit's end pondering over it?
How to make the SUBSTITUTE function work for each individual digit?
Sub Provaregress() r = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$J$2:$J$r") _ , ActiveSheet.Range("$K$2:$M$r"), False, False, 99, "ANOVA", False, _ False, False, False, , False Cells.Select Cells.EntireColumn.AutoFit Range("A1").Select End Sub
But it gives me an error. The only way i was able to do it without error was:
Code: Sub Provaregress() Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range("$J$2:$J$53968") _ , ActiveSheet.Range("$K$2:$M$53968"), False, False, 99, "ANOVA", False, _ False, False, False, , False Cells.Select Cells.EntireColumn.AutoFit Range("A1").Select End Sub
But as u can see it has a fixed number of rows. ( I need variable number of rows detected on column J, and then run regression with K,L,M as depending variables).
I have a control chart macro which is being used for patient doses of a medication. Right now my macro automatically fills columns D-N down to row 100. However, I would like it to stop at the last row of data entered in column A. I have attached the code related to the formulae a
I have a workbook with several sheets that have basically the same template but some have many more rows that others..
I am using the following code to hide columns based on cell value to "tidy it up" for printing.
Code: Dim i As Long For i = 170 To 2 Step -1 Cells(39, i).EntireColumn.Hidden = Cells(39, i).Value = "N" Next i
I would like the VBA to determine what the row number is based on the row header e.g. "Prioritised Courses", rather than having to maintain the code each time new rows are added.
I would put it at the top or way down the bottom, but multiple (even less excel skilled) users will be using the "hide columns" functionality.
i want a macro that will start on D25 and enter a 1 for five rows up to D29 than change and enter a 2 starting on d30 and enter a 2 for five rows up to D34 than change an enter a 3 up to D39 ....... on and on up D225.
The item_description is a combination of XXX, Part_no and Part_description all clubbed randomly. ( So I cannot use text-to-columns to bifurcate them).
Now Sheet B contains the part_number as follows :
SlNos, Part_no, ….,….,
I need a macro ( a procedure / function ) in Excel-vba, which would select each part_no in sheet – B one by one, find all those rows in which it appears in Item_Description column of Sheet-A and add a comment in the next column to it.
The Vlookup function cannot be used as it is not an exact match as the part_no is embedded among other things in item_description.
I've then used a simple count formula to add up the number by each stage and it's these numbers that I want the macro to use when determining how many rows to input.
Complete2Reporting1In Progress1Planning1
A second worksheet hosts the desired output - a simple report template, split into stages for each status type (completed, planning etc.) with the correct number of rows for each.
Completed AuditsCharlieDeltaReportingBetaAudits in ProgressAlphaAudits in PlanningOmega
So, I want the macro to ensure that we have the right number of rows for each stage, as this month will be run on a monthly basis and the stage each audit is at will change, and the number of rows required in each section will also be different.