Hi everyone,
I want to create a command button that adds a column be4 a specified value every time is clicked.
I figured i might just search the row containing this value "Targets" and return is index, then use that
index as a basis to insert a new column.
I do find the target and its index , but it is not inserting my column.
I know there could be better code more guaranteed to work. some body can help.
All the Best![]()
Private Sub CommandButton2_Click() Dim rng(5 To 25) As Variant, K As Integer ' dynamically assign the entire value of ranges to the array For K = 5 To 25 'search from C to Z rng(K) = Cells(5, K).Value If (rng(K) = "Targets") Then Columns((K + 4)).Insert Debug.Print K Debug.Print rng(K) End If Next K End Sub
Bookmarks