tags:

views:

125

answers:

1

I have an excel sheet and on column J, I have a start number and on column K I have a end number... I want to write a macro that will read the start number in hex and print all the number including the number in between starting in column L.

This is what I have:

..........J...K.....L...M....N..O
.........1A...1C
.........2B...2B

I would like to:

..........J...K.....L....M....N..O
.........1A...1C....1A...1B..1C
.........2B...2B....2B
A: 
Option Explicit
Sub FillHexNumbers()
Dim cellJValue As Long
Dim cellKValue As Long

Dim diffBetweenJAndK As Long
Dim iCtr As Long

cellJValue = CLng(Format("&h" & Cells(1, 10).Text, "###"))
cellKValue = CLng(Format("&h" & Cells(1, 11).Text, "###"))

diffBetweenJAndK = cellKValue - cellJValue
For iCtr = 0 To diffBetweenJAndK
    Cells(1, 12 + iCtr).Value = Hex(cellJValue + iCtr)
Next
End Sub

This code will fill the cells only for Row 1.
Please modify to include the other rows by introducing a for loop.

shahkalpesh
Thanks shahkalpesh.... when I run it gaves me a error..Run-time error '13':
FANTASTIC... shahkalpesh... I just realized row 1 was my title...fixed.. now working.... thank you for all the help.