Never Ending Loop
Sep 8, 2008the followng code should execute once but it seems to just keep going round in a loop.
View 12 Repliesthe followng code should execute once but it seems to just keep going round in a loop.
View 12 RepliesI am trying to start in cell A1, and loop down. Each time a value is found, I want to insert a blank row, which is working, but I just can't figure out how to end this, it goes to the very last cell in column A and gives a debug error. I would like to to just go back to cell A1 after all rows have been inserted.
Sub Insert()
Range("A1").Select
Do
Selection.End(xlDown).Select
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Value = ""
End Sub
I have a do while loop that runs until the reference cell is empty. This has been working but now I have changed the reference cells somewhat so that the cells contain a formula that returns nothing if a function returns 0 or an error. So the cell has no value but it does have a formula in it. The do while loop keeps running because it thinks that the cell has something it it.
Do While Cells(i, 2) ""
Is there something else that i can put for "" to get the loop to stop when cell contains no value but a formula.
I'm looking for a way to take a number (23.89145 or $3.45 for instance) and use a formula to force it to end in a 4 at two decimal places (23.84 or $3.44)...generally only interested in going down.
View 3 Replies View RelatedI have a macro that continues to tell me that an End With and/or End Sub is expected. I continue to add these statements in various ways, but the macro will not complete properly.
Here is the
I have a macro I use cleanup up excel data I paste into it. Currently I paste in data that is three columns but there is space between the different items. For example:
View 2 Replies View RelatedIn my sample workbook, (attached), all I want to do is up a formula in column E that compares values in columns A, B and C. If they are the same, I want to put the last year model in Column E.
I have filled in the first 12 rows to whow the desired result. Ultimately, for each part number and model combination, I want to put the final year for that combination in column E. The sample workbook constains just a few rows, but my master has about 30,000 rows.
After the last line of data, I do not want ton's of blank columns. I know you can scroll down with your mouse to see more columns, but after I run my VBA script, there is a good 1200 blank rows below the last data row.
Is there a VBA line to say end after last row containing data.
Ex. I have 335 rows of data. So there should be like 350 rows total (with a few blanks preferably none or 1, but not sure how hard this is) instead of 1500 total.
Reason I ask is that for some strange reason a program I use is pulling in those extra blank lines which is screwing up my import job.
I have data that is added to every week. I need an equation to count how many times each employee show up each weekending.
View 3 Replies View RelatedI am trying to create a week ending formula in excel. I have a list of dates and in a new column I would like to display the week ending of these dates. I want the weeks to end on Sunday. For example, if the date column has the date 7/24/12 in it, I would like the week ending formula to spit out 7/29/12. What formula would achieve this?
View 5 Replies View Relatedwhere i can grab a number from a cell it would ALWAYS be the last string item..
for example if cell A1 has the following text:
04/02 Card Purchase 03/31 Google*1873060297 Cc@Google.Com CA Card 5036 $500.00
i want cell B1 to hold just the $500
this wold always be the case for everything im trying to do
I have the following code that I use to create individual client files from one master spreadsheet. My problem is that it always creates and saves a blank file with only the 'rn' value in the file name. It seems that it is looping one extra time when the 'rng.value' list ends.
Sub MakeFiles()
Dim wb As Workbook
Dim ws As Worksheet
Dim criteriaRng As Range, usedRng As Range, rng As Range
Dim lh As String, ch As String, rh As String
Dim rn As String
[code]....
Here's my problem. I need a formula to take the decimals out of a column but keep ending zeros. I have tried find/replace & several formulas but nothing seems to be working. Here is an example of the numbers in the column and the end result I need.
9.66 966
0.50 050
13.09 1309
309.98 30998
how to delete complete rows that in column a end in the letter A
View 6 Replies View RelatedI am working on code to detect whether a cell contains an even or an odd number in it. I can do this when I know that the numbers I want to evaluate are in cells A1 trough A10 but the next part of the code is for when we do not know how many entries there are and we have to evaluate until we come across an empty cell and then stop.
View 2 Replies View RelatedI have many regularly used workbooks with financial data in them. Many times the financial data needs to be adjusted due to rounding issues. To do this I add a +1 or -1 or sometimes it is in decimal form +/- .1 Also the number "1" is not always (but almost always) used. There are some circumstances where I may add + 2 or +6 or any small number to the end of a formula.
My problem is that when I use the file again after making these changes, I am wanting to remove the "adjustments" I have made to the formulas. Sometimes a green triangle will appear in my cell telling me the formula does not match that of other near-by cells, and that is good, but it is not consistent enough to find them all, or even most of them.
What I am wanting is a macro I can run that will identify any cell with these "adjustments" I have added to them and I will then go in and delete the +/- 1 or whatever the number is. I can easily do a Find "+1" for the entire workbook, it is the range of possible numbers that is preventing me from doing a simple ctrl + f.
I have a list of numbers in which I need to return the last 5 digits; the length of the string may vary.
However, if the last two digits of the number ends in a specific value then it should skip over the last two numbers and return the preceding 5 digits.
I have tried and have used the very basic Left, Right and Mid functions. My problem is I dont know how to code the formula to identify the last two digits and skip over them, if necessary.
I have provided an attached example.
Extract numeric value based upon ending characters.xlsm
I'm trying to create a formula which will allow me to do the following
1. Enter the number of jobs received
2. Divide it by the staff available without ending up with decimals.
As an example. Say I have 60 jobs to be allocated and there are 13 peeps to distribute them to I'm currently getting 4.62. What I need to do is make sure that the jobs are only issued as whole numbers. E.g 5 peeps gets 4 and 8 get 5. I also need to factor in jobs on hand etc but I have already cracked this.
In Column A i have a long list of alphanumeric words , some of them end with a vowel "aeiouy". I want a macro that will go thru the list in A, and check if word in a cell end with a vowel, then put it in B column, so that in B i will have all the words ending with a "AEIOUY".
View 5 Replies View RelatedHow I can deselect the selected cells before ending the macro. Ihave a workbook containing about 40 sheets, and need to clear the same cells on 31 of them. I have attempted to define a name for the range, and actually got it to work once, however it ceased working on the second attempt, and I don’t know why. I have therefore gone back to the original code as posted below.
My questions are a) how can I deselect all the cells and b ) how can I use a defined name for the range so that I can use something like clear contents and not have to select the cells?
(I have also cleared all unlocked cells previously, but I have some unlocked cells in the other sheets I do not wish to clear).
Subnewmonth()
' newmonthMacro
IfMsgBox("This deletes all data, do you wish to continue?", vbYesNo) = vbNo Then Exit Sub
Sheets(Array("1","2", "3", "4", "5", "6","7", "8", "9", "10", "11","12", "13", "14", "15", _
"16", "17","18", "19", "20", "21", "22","23", "24", "25")).Select
Sheets("1").Activate
Sheets(Array("26","27", "28", "29", "30","31")).Select Replace:=False
[Code] ..........
I have a sheet called "Words Ending In"
In ColA From A 3 downwards I have a large list of keyword phrases.
I am looking for a macro where I click on a assigned macro button and a pop up box appears saying
" Find words Ending With"
In the space provided I insert a word.
So, for example I insert the word "rent".
The macro then looks at all the data in ColA (From A 3 downwards) and searches for all keyword phrases ending with the word "rent".
If it could return All Phrases in ColC (From C3 downwards).
If it can't find any, then if a pop up box can appear saying something like "No Data Found"
That's it really.
If it could have a pop up box at the end saying
"Total Phrases Scanned: 1234"
" Total Phrases Found Ending With "In"
"Time Elapsed (sec.): 12.12353
I need a formula to sum all E3 cells starting from sheet "Joe" to the last sheet i have, without being obliged to modify the formula for each new sheet i create and which by default is created in the end. something like:
=sum(Joe:my last sheet created!E3)
Also,do protected cells in some of the sheets affect this formula calculation?
I am working with a somewhat lengthy worksheet with over 60,000 records. oOne of the columns within the worksheet is the "Account Number" column, which typically consists of 14 numerical characters, but can sometimes have additional or fewer characters. I need to set up a conditional format to pick up any account number that ends in an alphabetical value, (e.g. a through z). The account number is located in column G.
View 4 Replies View RelatedI have some data in a column, starting at row 6 that I'd like to find the number of unique text values for. For this I have been using this formula
Code:
{=SUM(IF(FREQUENCY(IF(LEN(A6:A10000)>0,MATCH(A6:A10000,A6:A10000,0),""), IF(LEN(A6:A10000)>0,MATCH(A6:A10000,A6:A10000,0),""))>0,1))}
The data is dynamic so I picked an arbitrarily large number (10000) and the above formula successfully ignores blank fields.
However, I'd like to now find the count of unique text values that end in X. For example, let's say the data are as follows
Dog_Cat
Mouse_Dog
Mouse_Cat
Mouse_Cat
Mouse_Cat
Mouse_Mouse
Elephant_Elephant
How would I go about (in one function) finding the unique values that end in "_Cat", in this case 2 ("Mouse_Cat" and "Dog_Cat")?
Is there a way to display just the staring and ending labels in a line graph.
I have around multiple line items, each contiaining 15-20 data points.
When I instert line graph with data labels, it becomes very mesy.
So I want to display just the starting and ending number of each line graph.
Manually selecting the data point and adding labels is very time consuming as I have around 200 line graphs, each containing 7-8 data series.
I am using Excel to use stock ticker symbols such as FDX "Fedex", to return past volume and price daily performance found in Google Finance that will be manipulated with the current VBA I am working on that will result in a trading pattern. Each trading pattern will happen at a different range in the same column. I will be inputting hundreds of ticker symbols daily so using VBA and not having to enter formulas manually in each is greatly preferred as this will save me lots of time.
I am stuck trying to find the average value of a range starting from the minimum to the maximum value. For instance, Range("H10:H20") may have a maximum value at range("H12") and a minimum at Range("H18"). I would like the average of Range("H12:H18").
Sub Fnd()
Dim MaxStartPriceRange As Range
Dim MinStartPriceRange As Range
Dim MaxPriLocation As Double
Set MaxStartPriceRange = Range("h11:h21")
MaxPriLocation = Application.Max(MaxStartPriceRange)
Set MaxStartPriceRange = MaxStartPriceRange.Find(MaxPriLocation)
Dim MnPriLocation As Double
I am just looking for a way to use the find function but only to display results that end in what I am looking for. For example i am trying to find a sequence of numbers/letters that end in a. If I do a find it displays results for anywhere there is a . in the sequence. I would like just the ones that end in the.
View 2 Replies View RelatedI have a list of entrys (41 in total so far) from cell A1 down starting with the value 1. This entry represents the week ending 04/06/06. ie each entry represents a date for the week ending. So cell A2 will contain the no 2 and represent the week ending 11/06/06. Cell A3 will contain the no 3 and represent the week ending 18/06/06. It goes in order right down to number 41. I have a userform, what I want to do is have a combobox load all the entrys in as dates, not as the entry no. Then when I choose a week in the combobox it will load the appropriate entry no into another textbox? I dont want to add the dates to the spreadsheet.
View 4 Replies View RelatedI would like to extract competition naps from the competition entries and then remove the string ending "nap" from the data so it can be pasted to another sheet in it's 'clean' format.
on the example sheet column B will always be the first column and the range will extend to either G,H or I (always the max range as there are always 6 to 8 races)
i would like the code to search through these columns of data and find the cell ending in 'nap' then to return this in column i, once done remove 'nap' ending from both the source cell and column i.
once done to then go through all the rows and do similar
the end result would be all naps returned into cell j and all the 'nap' endings through the data range B to I (max) to be removed to leave the horses name only.
in book 3 the first row nap was sommersturm so i have shown the outcome i would like with the nap ending in I1 removed and the horse name returned in J1 again minus 'nap' ending.
the data will always be clean with no leading/trailing/excessive spaces and always be lower case too. sometimes a space is not in between horse name and nap but it's always last 3 characters i want removed still.
How to modify a custom cell format to make data entry easier.
My goal is to have the output look like this: 'A12B-C20D: SET 10: Text string here'
Inputs needed are:
1-3 digit number between A & B
1-3 digit number between C & D
1-2 digit number after SET
Text string of variable length
Where I am stuck. So far I can get "A12B-C20D: SET 10:" to show up properly when 122010 is input. The custom format I am using looks like this: "A"##"B-C"##"D: SET "##": "
When I try to incorporate the "@" symbol the first part of the formatting goes away and the output shows up as "122010 Text string here".
I have tried:
"A"###"B-C"###"D: SET "##":";;-;_@
"A"###"B-C"###"D: SET "##": ";;@
"A"###"B-C"###"D: SET "##":";_@
"A"###"B-C"###"D: SET "##": ";;;@