Excel VBA - Add Data Labels from Table body range
up vote
0
down vote
favorite
I have an Excel worksheet with a table that contains columns for project name, x, y, size in order to create a bubble graph.
I would like it to change the Data labels to be equal to the respective project name but how do I do that? I've searched on the web for solutions but neither of them with succes.
Here's my data:
- Chart name: Chart 1
- Table name: Table (This one have headers and I'm
only searching for the range within the table (data body range).
Here's my code which gives me the error 91:
Sub InsertLabelnameBubble()
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table").Rows.Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table").Cells(i, 1)
Next i
End Sub
Here's a screenshot of my project.
Where you can see that it uses the Y column (Expected project potential) as the data label text. What I would like it to do is that it should take it from the first column in my table (Project #).
excel vba excel-vba range bubble-chart
add a comment |
up vote
0
down vote
favorite
I have an Excel worksheet with a table that contains columns for project name, x, y, size in order to create a bubble graph.
I would like it to change the Data labels to be equal to the respective project name but how do I do that? I've searched on the web for solutions but neither of them with succes.
Here's my data:
- Chart name: Chart 1
- Table name: Table (This one have headers and I'm
only searching for the range within the table (data body range).
Here's my code which gives me the error 91:
Sub InsertLabelnameBubble()
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table").Rows.Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table").Cells(i, 1)
Next i
End Sub
Here's a screenshot of my project.
Where you can see that it uses the Y column (Expected project potential) as the data label text. What I would like it to do is that it should take it from the first column in my table (Project #).
excel vba excel-vba range bubble-chart
3
Maybe include some screen shots. Doesn't seem clear what you're asking for.
– PGCodeRider
Oct 31 at 14:28
1
Also, which line are you receiving the error? Error 91 means you are trying to use an object set to Nothing
– Kubie
Oct 31 at 14:33
2
See The VBA Guide To ListObject Excel Tables for how to properly access a table in Excel VBA. You must probably use something likeActiveSheet.ListObjects("Table").DataBodyRange(i, 1)
– Pᴇʜ
Oct 31 at 14:41
Am I allowed to upload my project file somewhere and post the link here? I'm not sure a screenshot is enough, and I'm really searching for a solution, which should be included in my Master's thesis.
– Rasmus Holt Hansen
Nov 1 at 11:19
You could manually link your labels to cells. Use a formula to pull the correct project name into a specific cell and then click your label twice before selecting the formula bar and then your cell. John Peltier explains it on his site - third heading.
– Darren Bartrup-Cook
Nov 5 at 14:17
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an Excel worksheet with a table that contains columns for project name, x, y, size in order to create a bubble graph.
I would like it to change the Data labels to be equal to the respective project name but how do I do that? I've searched on the web for solutions but neither of them with succes.
Here's my data:
- Chart name: Chart 1
- Table name: Table (This one have headers and I'm
only searching for the range within the table (data body range).
Here's my code which gives me the error 91:
Sub InsertLabelnameBubble()
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table").Rows.Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table").Cells(i, 1)
Next i
End Sub
Here's a screenshot of my project.
Where you can see that it uses the Y column (Expected project potential) as the data label text. What I would like it to do is that it should take it from the first column in my table (Project #).
excel vba excel-vba range bubble-chart
I have an Excel worksheet with a table that contains columns for project name, x, y, size in order to create a bubble graph.
I would like it to change the Data labels to be equal to the respective project name but how do I do that? I've searched on the web for solutions but neither of them with succes.
Here's my data:
- Chart name: Chart 1
- Table name: Table (This one have headers and I'm
only searching for the range within the table (data body range).
Here's my code which gives me the error 91:
Sub InsertLabelnameBubble()
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table").Rows.Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table").Cells(i, 1)
Next i
End Sub
Here's a screenshot of my project.
Where you can see that it uses the Y column (Expected project potential) as the data label text. What I would like it to do is that it should take it from the first column in my table (Project #).
excel vba excel-vba range bubble-chart
excel vba excel-vba range bubble-chart
edited Nov 5 at 10:36
Pᴇʜ
19.8k42650
19.8k42650
asked Oct 31 at 14:24
Rasmus Holt Hansen
11
11
3
Maybe include some screen shots. Doesn't seem clear what you're asking for.
– PGCodeRider
Oct 31 at 14:28
1
Also, which line are you receiving the error? Error 91 means you are trying to use an object set to Nothing
– Kubie
Oct 31 at 14:33
2
See The VBA Guide To ListObject Excel Tables for how to properly access a table in Excel VBA. You must probably use something likeActiveSheet.ListObjects("Table").DataBodyRange(i, 1)
– Pᴇʜ
Oct 31 at 14:41
Am I allowed to upload my project file somewhere and post the link here? I'm not sure a screenshot is enough, and I'm really searching for a solution, which should be included in my Master's thesis.
– Rasmus Holt Hansen
Nov 1 at 11:19
You could manually link your labels to cells. Use a formula to pull the correct project name into a specific cell and then click your label twice before selecting the formula bar and then your cell. John Peltier explains it on his site - third heading.
– Darren Bartrup-Cook
Nov 5 at 14:17
add a comment |
3
Maybe include some screen shots. Doesn't seem clear what you're asking for.
– PGCodeRider
Oct 31 at 14:28
1
Also, which line are you receiving the error? Error 91 means you are trying to use an object set to Nothing
– Kubie
Oct 31 at 14:33
2
See The VBA Guide To ListObject Excel Tables for how to properly access a table in Excel VBA. You must probably use something likeActiveSheet.ListObjects("Table").DataBodyRange(i, 1)
– Pᴇʜ
Oct 31 at 14:41
Am I allowed to upload my project file somewhere and post the link here? I'm not sure a screenshot is enough, and I'm really searching for a solution, which should be included in my Master's thesis.
– Rasmus Holt Hansen
Nov 1 at 11:19
You could manually link your labels to cells. Use a formula to pull the correct project name into a specific cell and then click your label twice before selecting the formula bar and then your cell. John Peltier explains it on his site - third heading.
– Darren Bartrup-Cook
Nov 5 at 14:17
3
3
Maybe include some screen shots. Doesn't seem clear what you're asking for.
– PGCodeRider
Oct 31 at 14:28
Maybe include some screen shots. Doesn't seem clear what you're asking for.
– PGCodeRider
Oct 31 at 14:28
1
1
Also, which line are you receiving the error? Error 91 means you are trying to use an object set to Nothing
– Kubie
Oct 31 at 14:33
Also, which line are you receiving the error? Error 91 means you are trying to use an object set to Nothing
– Kubie
Oct 31 at 14:33
2
2
See The VBA Guide To ListObject Excel Tables for how to properly access a table in Excel VBA. You must probably use something like
ActiveSheet.ListObjects("Table").DataBodyRange(i, 1)
– Pᴇʜ
Oct 31 at 14:41
See The VBA Guide To ListObject Excel Tables for how to properly access a table in Excel VBA. You must probably use something like
ActiveSheet.ListObjects("Table").DataBodyRange(i, 1)
– Pᴇʜ
Oct 31 at 14:41
Am I allowed to upload my project file somewhere and post the link here? I'm not sure a screenshot is enough, and I'm really searching for a solution, which should be included in my Master's thesis.
– Rasmus Holt Hansen
Nov 1 at 11:19
Am I allowed to upload my project file somewhere and post the link here? I'm not sure a screenshot is enough, and I'm really searching for a solution, which should be included in my Master's thesis.
– Rasmus Holt Hansen
Nov 1 at 11:19
You could manually link your labels to cells. Use a formula to pull the correct project name into a specific cell and then click your label twice before selecting the formula bar and then your cell. John Peltier explains it on his site - third heading.
– Darren Bartrup-Cook
Nov 5 at 14:17
You could manually link your labels to cells. Use a formula to pull the correct project name into a specific cell and then click your label twice before selecting the formula bar and then your cell. John Peltier explains it on his site - third heading.
– Darren Bartrup-Cook
Nov 5 at 14:17
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
This is code that I use for data labels from a range. Have found this on stackoverflow a while back:
Sub DataLables
Dim ws as worksheet, DataLR As Series, pts As Points, pt As Point, rngLabels As Range, IDi As Integer, ChtObj As ChartObject
Set ws = ActiveWorkbook.ActiveSheet
With ws
Set ChtObj = .ChartObjects("ChatName")
Set rngLabels = .Range("A5:A39")
Set DataLR = ChtObj.Chart.SeriesCollection(2)
DataLR.HasDataLabels = True
For Each pt In pts
IDi = IDi + 1
pt.DataLabel.Text = rngLabels.Cells(IDi).Text
pt.DataLabel.Font.Bold = True
Next pt
End With
End Sub
Let me know if this helps. It will update the data labels with the values in the range.
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
|
show 1 more comment
up vote
0
down vote
accepted
So I did find the solution myself. Here's my final code inserting labels from the Table into the Bubble Chart:
Sub DataLables()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table1[Project '#]").Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table1[Project '#]").Cells(i, 1)
Next i
End Sub
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This is code that I use for data labels from a range. Have found this on stackoverflow a while back:
Sub DataLables
Dim ws as worksheet, DataLR As Series, pts As Points, pt As Point, rngLabels As Range, IDi As Integer, ChtObj As ChartObject
Set ws = ActiveWorkbook.ActiveSheet
With ws
Set ChtObj = .ChartObjects("ChatName")
Set rngLabels = .Range("A5:A39")
Set DataLR = ChtObj.Chart.SeriesCollection(2)
DataLR.HasDataLabels = True
For Each pt In pts
IDi = IDi + 1
pt.DataLabel.Text = rngLabels.Cells(IDi).Text
pt.DataLabel.Font.Bold = True
Next pt
End With
End Sub
Let me know if this helps. It will update the data labels with the values in the range.
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
|
show 1 more comment
up vote
0
down vote
This is code that I use for data labels from a range. Have found this on stackoverflow a while back:
Sub DataLables
Dim ws as worksheet, DataLR As Series, pts As Points, pt As Point, rngLabels As Range, IDi As Integer, ChtObj As ChartObject
Set ws = ActiveWorkbook.ActiveSheet
With ws
Set ChtObj = .ChartObjects("ChatName")
Set rngLabels = .Range("A5:A39")
Set DataLR = ChtObj.Chart.SeriesCollection(2)
DataLR.HasDataLabels = True
For Each pt In pts
IDi = IDi + 1
pt.DataLabel.Text = rngLabels.Cells(IDi).Text
pt.DataLabel.Font.Bold = True
Next pt
End With
End Sub
Let me know if this helps. It will update the data labels with the values in the range.
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
|
show 1 more comment
up vote
0
down vote
up vote
0
down vote
This is code that I use for data labels from a range. Have found this on stackoverflow a while back:
Sub DataLables
Dim ws as worksheet, DataLR As Series, pts As Points, pt As Point, rngLabels As Range, IDi As Integer, ChtObj As ChartObject
Set ws = ActiveWorkbook.ActiveSheet
With ws
Set ChtObj = .ChartObjects("ChatName")
Set rngLabels = .Range("A5:A39")
Set DataLR = ChtObj.Chart.SeriesCollection(2)
DataLR.HasDataLabels = True
For Each pt In pts
IDi = IDi + 1
pt.DataLabel.Text = rngLabels.Cells(IDi).Text
pt.DataLabel.Font.Bold = True
Next pt
End With
End Sub
Let me know if this helps. It will update the data labels with the values in the range.
This is code that I use for data labels from a range. Have found this on stackoverflow a while back:
Sub DataLables
Dim ws as worksheet, DataLR As Series, pts As Points, pt As Point, rngLabels As Range, IDi As Integer, ChtObj As ChartObject
Set ws = ActiveWorkbook.ActiveSheet
With ws
Set ChtObj = .ChartObjects("ChatName")
Set rngLabels = .Range("A5:A39")
Set DataLR = ChtObj.Chart.SeriesCollection(2)
DataLR.HasDataLabels = True
For Each pt In pts
IDi = IDi + 1
pt.DataLabel.Text = rngLabels.Cells(IDi).Text
pt.DataLabel.Font.Bold = True
Next pt
End With
End Sub
Let me know if this helps. It will update the data labels with the values in the range.
edited Nov 7 at 15:38
answered Oct 31 at 15:18
Bojan Goldy
12
12
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
|
show 1 more comment
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
I'm not sure whether I'm doing it wrong or not, but I keep receiving the error: "Object variable or With block variable not set".. I have you copied your code into the worksheet macro, changed the chart name and the range to match, and placed a button to trigger the macro. What does this mean?
– Rasmus Holt Hansen
Nov 1 at 8:31
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
This should work. Please let m know if you still have issues. Thank you.
– Bojan Goldy
Nov 6 at 13:55
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
So now my vba looks like this, where I'm receiving an error ( ) in the marked line. Set ChtObj = .ChartObjects("Chart 1") Set rngLabels = .Range("Table1[Project '#]") Set DataLR = ChtObj.Chart.SeriesCollection(1) DataLR.HasDataLabels = True For Each pt In pts ' <--- Run-time error 424: Object required IDi = IDi + 1 pt.DataLabel.Text = rngLabels.Cells(IDi).Text pt.DataLabel.Font.Bold = True Next pt End With End Sub Also my range should not include the header (Set rngLabels) so how to achieve this as well?
– Rasmus Holt Hansen
Nov 7 at 10:01
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
.Range("A5:A39") - you need to update the range and specify the fist one you would like to take
– Bojan Goldy
Nov 7 at 14:43
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
I've tried that but I'm still receiving an error in the "For Each pt in pts": 424: Object required.
– Rasmus Holt Hansen
Nov 12 at 8:54
|
show 1 more comment
up vote
0
down vote
accepted
So I did find the solution myself. Here's my final code inserting labels from the Table into the Bubble Chart:
Sub DataLables()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table1[Project '#]").Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table1[Project '#]").Cells(i, 1)
Next i
End Sub
add a comment |
up vote
0
down vote
accepted
So I did find the solution myself. Here's my final code inserting labels from the Table into the Bubble Chart:
Sub DataLables()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table1[Project '#]").Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table1[Project '#]").Cells(i, 1)
Next i
End Sub
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
So I did find the solution myself. Here's my final code inserting labels from the Table into the Bubble Chart:
Sub DataLables()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table1[Project '#]").Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table1[Project '#]").Cells(i, 1)
Next i
End Sub
So I did find the solution myself. Here's my final code inserting labels from the Table into the Bubble Chart:
Sub DataLables()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
For i = 1 To Range("Table1[Project '#]").Count
ActiveChart.FullSeriesCollection(1).Points(i).DataLabel.Select
Selection.Formula = Range("Table1[Project '#]").Cells(i, 1)
Next i
End Sub
answered Nov 22 at 8:56
Rasmus Holt Hansen
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53085660%2fexcel-vba-add-data-labels-from-table-body-range%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Maybe include some screen shots. Doesn't seem clear what you're asking for.
– PGCodeRider
Oct 31 at 14:28
1
Also, which line are you receiving the error? Error 91 means you are trying to use an object set to Nothing
– Kubie
Oct 31 at 14:33
2
See The VBA Guide To ListObject Excel Tables for how to properly access a table in Excel VBA. You must probably use something like
ActiveSheet.ListObjects("Table").DataBodyRange(i, 1)
– Pᴇʜ
Oct 31 at 14:41
Am I allowed to upload my project file somewhere and post the link here? I'm not sure a screenshot is enough, and I'm really searching for a solution, which should be included in my Master's thesis.
– Rasmus Holt Hansen
Nov 1 at 11:19
You could manually link your labels to cells. Use a formula to pull the correct project name into a specific cell and then click your label twice before selecting the formula bar and then your cell. John Peltier explains it on his site - third heading.
– Darren Bartrup-Cook
Nov 5 at 14:17