SorryForTheStupidQuestion
New Member
- Joined
- Sep 7, 2018
- Messages
- 8
Hi All,
I am trying to teach myself VBA. I have created some examples that I am trying to solve but I have no actual need to complete these tasks (other than to learn the code itself). With that said, what I am trying to do in this example is create a macro that inserts a spin button in each cell in range (e2:e7) in this spreadsheet:
I was able to successfully do this above by first creating the spin button in cell E2 and then using this VBA code which I learn from a video to copy/paste additional spin buttons:
However, what I would like to do is to be able to learn how to write code so that rather than having to first create a spin button and then copy paste it using a macro I can instead run a macro that will create all spin buttons (including the first one). I recorded a macro where I create a spin button but I wasn't able to make any sense of the code.
I would also like to know if it is possible to make this part of the code dynamic;
Ideally this value would populate as the value in corresponding cell in C column but it didn't seem to like this when I tried it:
Any help would be greatly appreciated.
I am trying to teach myself VBA. I have created some examples that I am trying to solve but I have no actual need to complete these tasks (other than to learn the code itself). With that said, what I am trying to do in this example is create a macro that inserts a spin button in each cell in range (e2:e7) in this spreadsheet:
I was able to successfully do this above by first creating the spin button in cell E2 and then using this VBA code which I learn from a video to copy/paste additional spin buttons:
Code:
Sub SpinBoxGolf()
Dim Cyclecount As Long
For Cyclecount = 1 To 5
ActiveSheet.Shapes("Spinner 1").Copy
ActiveSheet.Paste
Selection.Top = Range("E" & Cyclecount + 2).Top
Selection.Left = Range("E" & Cyclecount + 2).Left
With Selection
.Value = 70
.Min = 50
.Max = 100
.SmallChange = 1
.LinkedCell = "D" & Cyclecount + 2
End With
Next Cyclecount
End Sub
However, what I would like to do is to be able to learn how to write code so that rather than having to first create a spin button and then copy paste it using a macro I can instead run a macro that will create all spin buttons (including the first one). I recorded a macro where I create a spin button but I wasn't able to make any sense of the code.
I would also like to know if it is possible to make this part of the code dynamic;
Code:
With Selection
.Value = 70
Ideally this value would populate as the value in corresponding cell in C column but it didn't seem to like this when I tried it:
Code:
With Selection
.Value = activesheet.range("c" & Cyclecount + 2).value
Any help would be greatly appreciated.