Skip to main content
Support is Offline
Today is our off day. We are taking some rest and will come back stronger tomorrow
Official support hours
Monday To Friday
From 09:00 To 17:30
  Friday, 05 October 2018
  0 Replies
  2.8K Visits
0
Votes
Undo
I am looking at this kutools, and was trying to test a couple of the VBA scripts before I purchase the software. I have come across this one, and am wondering what needs to be changed to allow more than 2 columns.

This is the code you have on your site:

Sub InsertValueBetween()
'Update 20130825
Dim WorkRng As Range
Dim Rng As Range
Dim outArr As Variant
Dim dic As Variant
Set dic = CreateObject("Scripting.Dictionary")
'On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
num1 = WorkRng.Range("A1").Value
num2 = WorkRng.Range("A" & WorkRng.Rows.Count).Value
interval = num2 - num1
ReDim outArr(1 To interval + 1, 1 To 2)
For Each Rng In WorkRng
dic(Rng.Value) = Rng.Offset(0, 1).Value
Next
For i = 0 To interval
outArr(i + 1, 1) = i + num1
If dic.Exists(i + num1) Then
outArr(i + 1, 2) = dic(i + num1)
Else
outArr(i + 1, 2) = ""
End If
Next
With WorkRng.Range("A1").Resize(UBound(outArr, 1), UBound(outArr, 2))
.Value = outArr
.Select
End With
End Sub


My issue is that sometimes I may have an excel spreadsheet that has columns A thru S, and other times I may have a sheet that has columns A thru Z. and my column that I need to base my add rows off of may not be the first one.

How can I modify this to allow me to select the entire spreadsheet, and then select the column that I want it to use for the sequential numbers?
There are no replies made for this post yet.