VBA: Copying string value from named cell to a declared string variable

I have this code.

Dim BenefitName As String

Dim Category As String

    BenefitName = Sheets(“Benefits”).Range(“B10”).Value

    Category = Left(Sheets(“Benefits”).Range(“F10”).Value, 1)

 

I have created a named range for B10 (ben1name) and a named range for F10 (ben1cat) and I want to use them in the code instead of the actual cell addresses, but I can’t work out how to do that. How do I assign the value of ben1name to BenefitName, and assign the first letter of ben1cat to Category? Any advice much appreciated.

By: David Pannell

Leave a Reply

Your email address will not be published. Required fields are marked *