Find Closest Space To The Left Of Specified Position And Then Split
Dec 9, 2013
I'm looking for a way to split a cell with text into two cells. The first cell can only contain up to 40 characters, the rest needs to go in the second cell. However, I don't want the text to be split in the middle of a word. So basically, if the text is in cell A1, I need to find the closest space to the left of position 40 in A1, and move anything to the right of this position to B1. Example:
A1: One green apple and a bucket of small onions that smell nice
I want to avoid this:
A1: One green apple and a bucket of small on
B1: ions that smell nice
I want to achieve this:
A1: One green apple and a bucket of small
B1: onions that smell nice
I have a very large workbook with multiple sheets and use macros to copy and paste all data as values, then delete some rows and columns depending on certain criteria. This starts at cell A1 and works right, then down.
This is then saved as a copy and distributed to a wide audience.
The problem is that when each page is opened up, the data shown is the bottom right of the whole sheet instead of the top left ( Panes are frozen for row and column headers).
StrMnthYear = Trim(Left(Range("A1"), _ InStr(1, Range("A1"), " ", vbTextCompare) + 4)) MsgBox StrMnthYear End Sub
I have a column of cells likes: 5/5058 Jack Daniels 5/29AA Crown Royal
I want to delete everything to the left of the first space. So it will look like: Jack Daniels Crown Royal
It has to be vba though. I have done alot of trim in just formulas but this is first time in VBA. The above code is one I found by searching but not sure what to do to modify it. This will be for range AM2:AM2000
I'm looking for a formula that pulls the text from a cell unti it hits a space. I'm using the formula below but keep getting #VALUE results. B1: =LEFT(A1,FIND(",",A1,1)). I know it's not that hard but can't figure it out.
I'm sure this is mighty easy, but I'm hoping to take Column A which currently has names written in it in the form "Joe Bloggs" and split it into two columns, "Joe" in Column B and "Bloggs" in Column C. All names are enterred seperated by a space.
I recently got this task by my work employer to transfer information from several non-organized Excel-documents into one, complete and organized one.
The thing I have to organize right now is a column with thousands of zipcodes and zones in one single cell, only separated by spaces, like this:
Zipcode Zone 115 54 Gothenburg 443 67 Skane
What I want to do is instead of having to go through 24h of braindead control/paste is to use some easy and fast function or script that could pull out the last piece of string of information in every cell in that column into its own separate cell.
Although I am using Open Office Calc/Gnumeric on Ubuntu Dapper, if a script is necessary and only work with Excel on Windows/Mac, that is no big problem for me to solve. So please, any suggestion is welcome.
I will attatch two examples for you to look at, to get the whole picture.
I am working on payment/cost estimator and am looking for some ideas and formula or macro help. Basically what I am trying to do is set up a calculator where you would input the payment you could afford and it will tell you how much you can spend on the equipment. The problems I am running into are that when you factor in the interest rate and commission, the payments are round numbers so I need the formula to find the closest value. Example- $250 payment. The payments in the table w/ the interest rates are $158, $248 and $350. I would need it to pick the corresponding equipment cost for the $248 payment.
Make sense? If a macro would be easier I am fine with that, just have limited experience setting one up.
I need to find which number in a row would be closest to zero, then display the associated name. The number can be negative. I used this, which works well if all the numbers are positive: =INDEX($C$1:$E$1,MATCH(MIN(C66:E66),C66:E66,0)). I'm running into a problem when the closest number is negative.
In the attached sheet, I am using !Staff times columns N and O to nominate a mid point break time relevant to the start,lunch break and finish times of a shift.
What I would like to do is match the result to the closest time from !Race Times Column D (highlighted green). So if for example the mid point of the shift is 10:37 (as in !Staff Times cell N23), it actually comes back with the !Race Times result of 10:35 which is the closest actual race.
Ideally I would like it to look both sides of the midpoint time until it came to the closest match, rather than always looking at an earlier time, or always a later time (eg the cell N79 has a value of 11:36, however the 2 race times are 11:35 and 11:40. Preference is it shows 11:35). If however the N79 result was 11:38 or 11:39, I would prefer it went to 11:40).
However if this is not possible then picking the next time in either direction will do.
Say i had a col of random numbers, and their corresponding probabilities of occurring;
Neglect the nature of the sample, its just gibberish and not of concern here. The question is, if i enter a value in column C, how do i find the closest corresponding number to it in col A, and subsequently return its nearest corresponding probability from col B? For example, say i entered 8 in C1, then the formula would need to find the closest number to 8 in col A, which is 7, and return from col B the value of 0.001636.
I have a list with all our company cars (300). I also have a list with all the transactions of the fuel cards (12000 lines). Now I need the find for every company car (exact match) the nearest fuel-consumption-date (closest match to the given starting date) and take the mileage of that transaction. I've added an example. I have tried linking carnr and date (like carnr&"#"&date) and match these, but I don't always get the right car number.
I have a database where I have groups defined. For example, Parent 0001 is called Bag1. It contains an apple, orange, grape, and a pear. Parent 0002 is called Bag2, containing an apple, orange, and a peach. So on and so on...
Below is an illustration of what I explained above:
I have modified some code I found in these forums that once I enter a value in a cell I can have it find the closest match to that value and scroll down the list and paste that value as an offset. The code works perfectly, but my data will often contain the same values repeated and these aren't duplicates and I need to know how to loop the code to ensure it doesn't just find the first value but also the second (if the first is already populated) Code is:
Sub findclose() Dim rng As Range, Dn As Range, Mx As Single, oAd As String Dim num As Range
Set num = ActiveSheet.Range("B1")
---- What I need to do is insert a loop of some sort that basically says IF my offset cell has a value then to find the next closest amount and continue the macro.
So if my list was:
700 50 500 600 500
And I wanted to find 499 then my list would look like:
700 50 500 499 600 500
BUT if I wanted to match off another amount of 501 it would keep the 499 it found and then find the 501 making the completed list look like:
700 50 500 499 600 500 501
Right now the amounts are being overidden as I don't know how to loop it...
I have a sheet of pump test results, placed in rows, where the test rig is set at a specific speeds and flow and it records pressure. At each stage of the test a number of snapshots will be taken (Usually between 3-5 at each stage), so I have 3-5 rows of very similar data. I only need to use the best row from the selection available, so I am hoping to find a formula or code (Don't care which) that can look at the results and select the row of readings where the speed AND the flow are closest to the targetted data.
For example: In cells G6:G8 I have flow result values 0.129, 0.151, 0.156 and in H6:H8 I have speed result values 72.536, 71.82, 72.13. These are actuals. In cell N6 I have the target speed (75) and in O6 I have flow target (0.15), but these could be moved anywhere to suit really. What I was hoping to do, but am struggling big time, was to just flag up the row of readings where these two values are closest to the targets by placing a check mark in column L:L which I have formatted in monotype sorts and would like to place a "4" (Which gives me a check mark) on the 'best' row. From that I can do more with some simple IF statements.
Is this feasible, or am I trying to do something beyond Excels capability, it is certainly beyond mine at the moment. I was looking at the check mark method, but that is not essential, so if anyone has any suggestions on an alternative means of identifying the best row of data, that might make it easier to do, then I am listening.