Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 14996

Programatically Change Number Values In A String

$
0
0
I am using VS 2008, and coding in VB.Net for an Excel 2007 Add-In.

I am looping through a range of cells and programatically changing the value within the cell. I have the code to accomplish this when the original value in the cell is a single number....
Code:

Dim rng As Range
Dim cel As Range

rng = ActiveSheet.Range("A1:A10").Cells

For Each cel In rng
    cel.Value = cel.Value + 10
Next cel

My problem arises when the original value of the cell is a string like this: 16 - 18

I am pretty sure I am going to have to add IF - Then - Else to this loop. But, I can't seem to figure out how to progamatically find and change the numeric values in this cell to: 26 - 28

Viewing all articles
Browse latest Browse all 14996

Trending Articles