P
poppy
Good Day
I'm writing a Macro that must find all fields that start with a space
and move them to another column depending on the number of spaces.
Eg.from this
Code:
--------------------
Carrots 6
Onions 7
Veggies 13
Bananas 5
Oranges 9
Apples 2
Fruits 16
Fridge 29
--------------------
To this:
Code:
--------------------
Carrots 6 Veggies 13 Fridge 29
Onions 7 Veggies 13 Fridge 29
Bananas 5 Fruits 16 Fridge 29
Oranges 9 Fruits 16 Fridge 29
Apples 2 Fruits 16 Fridge 29
--------------------
I'm thinking of something like this in terms of code:
Code:
--------------------
Sheets("Sheet1").Select
' Start moving fields
ActiveWorkbook.Names.Add Name:="Start", RefersTo:=Range("A6")
Range("Start").Select
Do
If ActiveCell.FormulaR1C1 = " " & (Whatever is contained in the field) Then
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Cut
End If
ActiveCell.Offset(1, 0).Activate
Loop Until ActiveCell.Value = ""
I'm writing a Macro that must find all fields that start with a space
and move them to another column depending on the number of spaces.
Eg.from this
Code:
--------------------
Carrots 6
Onions 7
Veggies 13
Bananas 5
Oranges 9
Apples 2
Fruits 16
Fridge 29
--------------------
To this:
Code:
--------------------
Carrots 6 Veggies 13 Fridge 29
Onions 7 Veggies 13 Fridge 29
Bananas 5 Fruits 16 Fridge 29
Oranges 9 Fruits 16 Fridge 29
Apples 2 Fruits 16 Fridge 29
--------------------
I'm thinking of something like this in terms of code:
Code:
--------------------
Sheets("Sheet1").Select
' Start moving fields
ActiveWorkbook.Names.Add Name:="Start", RefersTo:=Range("A6")
Range("Start").Select
Do
If ActiveCell.FormulaR1C1 = " " & (Whatever is contained in the field) Then
Range(ActiveCell, ActiveCell.End(xlToRight)).Select
Selection.Cut
End If
ActiveCell.Offset(1, 0).Activate
Loop Until ActiveCell.Value = ""