excel - Extract values from cell and copy entire row with each individual value -
I have a column in which there is 3 digit code giving reference to a branch if someone is working in several departments , Then he will have many codes in that column. What will be the following.
names | Branch ABC | 423 Mno 367325 XYZ | 414426429 I want to see it this way.
names | Branch ABC | 423 Mno 367 MNOs | 325 xyz. 414 xyz | 426 XYZ | 429 I want to remove the value of the cell, suppose that the length of the string is 9, then that person works for 3 branches. I want to remove those 3 values and duplicate the entire row with each row with one line number. Some indications: No one can work for more than 3 branches (This will be the maximum string length 9 ). There are approximately 20 columns columns containing branch codes, they are always the same. I.e. Columns . Columns have empty cells and other string values such as ' BIKCJHGT ' entire columns are formatted as text. Can anyone give me VBA code to complete this?
Here is the code I used to have not thrown any errors, but it is not working either.
Option Clear sub multicache () Set as DimB workbook b = Workbooks. (Activate ActiveSheet.Range ("G1") ("C: \ user \ uspola00 \ Desktop" "Headcount". Design as Worksheet Set ws = Sheets ("headcount") Dimension like dim intranetro I am long enough = 1 application.ScreenUpdating = Incorrect I & gt; Ws.Range ("G" and Rows.Count) .and (XLEEP) .ro Dim String String str = LTrim (RTrim (ws.Range ("G" & amp; I))) If the lane ("g"; i) = 9 then integer Rows = 2 range ("G" and I + 1 and G: "G" and I + + internator). Antirevo Insertate Range ("A" and I and A: "N" & amp; ("G" and (i + intInsertRows). Filldown Range ("G" and (I + IntranTrO)) Value = Right (Str, 3) Range ("G" and "I + 1") Value = Mid (str, 4, 3) range ("G" & amp; i). Value = left (str, 3) i = i + intInsertRows ALSIIF lane "G" & amp; i) = 6 then intInsertRows = 1 range ("G" & amp; I; Amp; ": G" and I + intInsertRows) .EntireRow.Insert Range ("A" & amp; & Amp;:: & amp;; N & amp; ((i + intInsertRows)) FillDown Range ("G" & I + IntInsertRows) Value = right (str, 3) range ("g" & amp; i). Value = left (str, 3) i = i + intInsertRows LCIF lane ("G" & amp; i) = 3 then intInsertRows = 0 i = I + intInsertRows ElseIf isEmpty (range ("G" & amp; i)) then I = i + 0 end if i = i + 1 loop ending sub
try it :
sub-multicorders () Dim box workbook as a diminished worksheet, in the form of Dim, v, i as long set b = workbooks.Open ("C: \ users Set \ uspola00 \ Desktop \ Headcount_Final.xlsx ") set ws = b.Sheets (" Headcount ") c = ws.Cells (rows.kount," g "). End (XLeEp) V = Trim (C. Well) If like "######" like V or "#########" then I = Lane (V) / 3C. Offset (1, 0). Recycling (i-1) .InterroroIncent C. RISIS (i) EntireRow.FillDown c.Value = Left (v, 3) c.Offset (1, 0) .Value = Mid (v, 4, 3) If lane (v) = 9 then c.Offset (2, 0). Value = true (V, 3) End if c.row = 1 then exit set c = c.Offset (-1, 0) loop ending sub
Comments
Post a Comment