Houstonking
New Member
- Joined
- Jul 12, 2016
- Messages
- 41
Hello I have below Data - and my end goal is to reach the data in next column - I have already recorded the macro but I want it to run till there is data on the left hand column - in my example I have only 20 rows.
so what I am doing I just takin left data and adding it"" example - if 123 --- then "123",
[TABLE="width: 96"]
<colgroup><col width="64" style="width: 48pt;" span="2"><tbody>[TR]
[TD="width: 64, bgcolor: transparent"]Data
[/TD]
[TD="width: 64, bgcolor: transparent"]Query
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]334[/TD]
[TD="bgcolor: transparent"]'334',
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]667
[/TD]
[TD="bgcolor: transparent"]'667',
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]75757[/TD]
[TD="bgcolor: transparent"]'75757',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]35353[/TD]
[TD="bgcolor: transparent"]'35353',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]887[/TD]
[TD="bgcolor: transparent"]'887',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]254546[/TD]
[TD="bgcolor: transparent"]'254546',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]6555[/TD]
[TD="bgcolor: transparent"]'6555',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4343434[/TD]
[TD="bgcolor: transparent"]'4343434',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4432323[/TD]
[TD="bgcolor: transparent"]'4432323',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3233223[/TD]
[TD="bgcolor: transparent"]'3233223',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]334[/TD]
[TD="bgcolor: transparent"]'334',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]667[/TD]
[TD="bgcolor: transparent"]'667',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]75757[/TD]
[TD="bgcolor: transparent"]'75757',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]35353[/TD]
[TD="bgcolor: transparent"]'35353',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]887[/TD]
[TD="bgcolor: transparent"]'887',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]254546[/TD]
[TD="bgcolor: transparent"]'254546',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]6555[/TD]
[TD="bgcolor: transparent"]'6555',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4343434[/TD]
[TD="bgcolor: transparent"]'4343434',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4432323[/TD]
[TD="bgcolor: transparent"]'4432323',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3233223[/TD]
[TD="bgcolor: transparent"]'3233223',
[/TD]
[/TR]
</tbody>[/TABLE]
Sub CellQuery()
'
' CellQuery Macro
'
'
ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Select
ActiveCell.FormulaR1C1 = "Query"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=""'""&RC[-1]&""'""&"","""
ActiveCell.Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:A20")
ActiveCell.Range("A1:A20").Select
End Sub
so how can remove the A1:A20 till it sees at on left hand for how many rows it has.
so what I am doing I just takin left data and adding it"" example - if 123 --- then "123",
[TABLE="width: 96"]
<colgroup><col width="64" style="width: 48pt;" span="2"><tbody>[TR]
[TD="width: 64, bgcolor: transparent"]Data
[/TD]
[TD="width: 64, bgcolor: transparent"]Query
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]334[/TD]
[TD="bgcolor: transparent"]'334',
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]667
[/TD]
[TD="bgcolor: transparent"]'667',
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]75757[/TD]
[TD="bgcolor: transparent"]'75757',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]35353[/TD]
[TD="bgcolor: transparent"]'35353',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]887[/TD]
[TD="bgcolor: transparent"]'887',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]254546[/TD]
[TD="bgcolor: transparent"]'254546',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]6555[/TD]
[TD="bgcolor: transparent"]'6555',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4343434[/TD]
[TD="bgcolor: transparent"]'4343434',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4432323[/TD]
[TD="bgcolor: transparent"]'4432323',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3233223[/TD]
[TD="bgcolor: transparent"]'3233223',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]334[/TD]
[TD="bgcolor: transparent"]'334',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]667[/TD]
[TD="bgcolor: transparent"]'667',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]75757[/TD]
[TD="bgcolor: transparent"]'75757',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]35353[/TD]
[TD="bgcolor: transparent"]'35353',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]887[/TD]
[TD="bgcolor: transparent"]'887',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]254546[/TD]
[TD="bgcolor: transparent"]'254546',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]6555[/TD]
[TD="bgcolor: transparent"]'6555',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4343434[/TD]
[TD="bgcolor: transparent"]'4343434',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4432323[/TD]
[TD="bgcolor: transparent"]'4432323',[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3233223[/TD]
[TD="bgcolor: transparent"]'3233223',
[/TD]
[/TR]
</tbody>[/TABLE]
Sub CellQuery()
'
' CellQuery Macro
'
'
ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Select
ActiveCell.FormulaR1C1 = "Query"
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=""'""&RC[-1]&""'""&"","""
ActiveCell.Select
Selection.AutoFill Destination:=ActiveCell.Range("A1:A20")
ActiveCell.Range("A1:A20").Select
End Sub
so how can remove the A1:A20 till it sees at on left hand for how many rows it has.