split value based on length and delimiter - vba - vba

Can any one help me on VBA script on split paragraph into difference cells with delimiter space and maximum character of 30 for each cell
Example
Split value in Cell A1 to A3 and A4
A1 ='I will not make the same mistake again' (38 Character)
A3 = 'I will not make the same' (24 Character)
A4 = 'mistake again' (13 Character)`
Thank in advance

Related

How to fill empty cells with values from upper non empty cell in libreoffice calc without using macro/coding

I want to fill empty cells with value from upper non-empty cells, ms excel have ctrl+d for doing that. but i want one step further I want to do multi hop ctrl+d.
For Example
A1, A3, A9, A25, A28 have some value and all other cells of column A are empty I want to fill cell A2 with value of A1,cells A4 to A8 with value of A3,cells A10 to A25 with value A9,cells A26 to A27 with value of A25
Other columns also have such empty cells and I want to fill them like I want for column A.
Folowing are images of sample excel:
I can fill the empty cells by grading cell down for each hop.
For given example I can fill cells by dragging down A1, A3, A9, A25, A28 each.
But I want to do that in one go because I have this type of empty cells and filled cells in between empty cell in thousands.
how can I do that?
Assuming the 1st table content is in A1:C15, put :
=IF(A2="",E1,A2) in E2
=IF(B2="",F1,B2) in F1
=IF(C2="",G1,C2) in G1
and drag downwards..
Hope it solves..
You might like this trick
Just use simple formula and Ctrl+Shift+V (Paste Special - Skip Empty Cells)

Using Regexp_substr to display specific text

I have a column called keys with data in this format:
qwert! B1 12345! B3 abcde! B4 fgh14777
stat! B3 3456! C0 224466! B2 bbmm
I'm trying to use regexp_substr to display only text that starts with B3 and end with a character before the next exclamation mark (!)
So my desired result would be this:
B3 abcde
B3 3456
B3 might be be on any position within the string and the length of the text might vary as well. Not every row contains B3.
Any help would be appreciated!
This is a pretty simple regular expression:
select regexp_substr('qwert! B1 12345! B3 abcde! B4 fgh14777', 'B3[^!]+', 1, 1)
from dual

For Excel VBA, If B2 value did not change then A2 will keep same, If B2 is changed then A2 will increase by one

I need a VBA for the whole column B and A says that
if Value of Cell B2 did not change then A2 value will be the same
if B2 value is changed then A2 value will increase by one
Use this formula.
Put your staring number in A1.
Put this in A2:
=IF(B2<>B1,A1+1,A1)
And copy down.

Copy a number starting with 0 in vba and paste is as such

say cell A1, A2, A3 contains value "00V", cell An contains value "029"
I'm doing a comparison for consecutive cells in column A like:
If A1 not equal to A2 then ill copy the cell value of A2 and paste it into a new worksheet in Column A first consecutively.
When I compare 00V and 029 (i.e. both are unequal) ill copy 029 and paste into new sheet
But "029" gets pasted as "29"
How do I fix this in Excel vba?
You could use Format(val, "000") where val is the value of whatever you're copying.
Or you could use rng.NumberFormat = "000" where rng is the destination range of where you're copying the values to.
Convert the target column format to text and then use paste special values. You'll be able to preserve the zeros.
The easiest way is to add a apostrophe (') in front of the values. When copied, the 0 will be maintained.

Nested 'For' cycle required

I have four cells in an Excel workbook:
A1
A2
A3
A4
A1 and A2 cells include starting values such as 5 and 7. A3 has an formula and evaluates a result using A1 and A2's values. A4 cell has a target value. An iterational operation continue up to A3 cell's value equal to A4's 0,0001 approximation. For each A1's differential increment A2 will change depending on its range.
Can anybody help me with VBA including nested 'For' cycles?
My sample workbook:
There is an add-in with excel that is built to do this, it's called the solver addin.
There's a good tutorial here that explains how it works.