Hi
I'd like to do 3 simple things with VBA, which I haven't done before.
i) I'd like to select a range, but ignore the last row, when selected.
So if I had the values a, b, and c in cells A1, A2, and A3, and the values 1, 2, 3, and 4 in cells B1, B2, B3 and B4, I'd like to select the range A1:B3, instead of A1:B4.
Please find below sample data:
[TABLE="width: 128"]
<tbody>[TR]
[TD="width: 64"]a[/TD]
[TD="width: 64, align: right"]1[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4[/TD]
[/TR]
</tbody>[/TABLE]
I tried this code, but it didn't work?
ii) I'd like to create a chart based on the data above (I recorded a macro - see below - but recorded macros only use a fixed range):
iii) I'd like to cut the newly created chart and paste it into cell M5 of Sheet 2.
Has anyone done this before?
If so, your help would be greatly appreciated.
TIA
I'd like to do 3 simple things with VBA, which I haven't done before.
i) I'd like to select a range, but ignore the last row, when selected.
So if I had the values a, b, and c in cells A1, A2, and A3, and the values 1, 2, 3, and 4 in cells B1, B2, B3 and B4, I'd like to select the range A1:B3, instead of A1:B4.
Please find below sample data:
[TABLE="width: 128"]
<tbody>[TR]
[TD="width: 64"]a[/TD]
[TD="width: 64, align: right"]1[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4[/TD]
[/TR]
</tbody>[/TABLE]
I tried this code, but it didn't work?
Code:
Sub ABC()
Sheet1.Activate
Range("A1", Range("B1").End(xlDown)).Offset(-1, 0).Select
End Sub
ii) I'd like to create a chart based on the data above (I recorded a macro - see below - but recorded macros only use a fixed range):
Code:
Sub Chart()'
' ChartMacro
Range("A1:B5").Select
ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
ActiveChart.SetSourceData Source:=Range("'count tab'!$A$1:$B$5")
End Sub
iii) I'd like to cut the newly created chart and paste it into cell M5 of Sheet 2.
Has anyone done this before?
If so, your help would be greatly appreciated.
TIA
Last edited: