• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Using C.Offset (Quick Simple Question)

Got a little stuck..


Function addStuffOnString(ByVal C As Range) returns the right value back (just in the wrong column).


Not sure if it's the function doing this or the Sub once it returns back.


As line 11 beneath indicates, I want the values to populate Column B (with Col A originally intact).


For some reason, the newly returned data keeps overwriting the original values in Column A (leaving nothing in Col B).


They won't offset over there in Col B for some reason?


Code:
Sub mySubName()

Dim c As Range

Dim myRange As Range


Range("A1") = "OrigVal1"

Range("A2") = "OrigVal2"

Range("A3") = "OrigVal3"


Set myRange = Range("A1:A3")


For Each c In myRange.Cells

c.Offset(0, 1).Value = addStuffOnString(c)

Next c


End Sub


Function addStuffOnString(ByVal c As Range)

c.Value = c.Value + " ..Appended To String (this should be in Col B)"

End Function
 
I just realized I'm doing something wrong in the function...

But it appears I still have a prob somewhere up top still.


Code:
Function addStuffOnString(ByVal c As Range)

c.Offset(0, 1) = c.Value + " ..Appended To String In Col B"

End Function
 
Shouldnt your function be:


Function addStuffOnString(ByVal c As Range)

addStuffOnString = c.Value + " ..Appended To String In Col B"

End Function
 
Back
Top