You've got a bit of a misconception of how assignments work.
You Dim'ed CHName as a string and then assigned the value of that
string to the value of a cell:
CHName = Sheets("Carddata").Range("Cardholder").Cells(1, 1).Value
later you conditionally assigned a new value to CHName
CHName = Me.CBName.Value
which overwrote the original assignment of the CHName - but heres's the
significant part - just because the original assignment of CHName's
value was to the value of a cell in the Cardholder named range, VBA
doesn't back-propagate a change in CHName's value to the cell value in
the named range.
To accomplish that, you would need something like
Sheets("Carddata").Range("Cardholder").Cells(1).Va lue =
Me.CBName.Value
As an aside, note that I replaced your .Cells(1,1) with .Cells(1). If
your names are to be stored in a single column named range Cardholder,
you can either use the .Cells(1) or Cells(1,1) notation, BUT the second
name in the named range would need to have a reference of .Cells(2) or
..Cells(2,1). Since the ,1 isn't doing anything for you (except perhaps
confusing you should you try to use .Cells(1,2) to get the value of the
second name in the Cardholder named range) I'd recommend the simpler
notation.
Also, note that if you want the most-recently entered name to be the
first choice, you are going to have to do some management of the names
in the Cardholder named range - that is, you are going to have to shift
any other names already in the Cardholder named range down before adding
the newest one to .Cells(1) - unless you work out some way to load the
names into the combobox from the bottom of the Cardholder named range up
to the top - in which case the newest name could be at the bottom of the
Cardholder range.
Hope this helps some...
--
jamescox
------------------------------------------------------------------------
jamescox's Profile:
http://www.thecodecage.com/forumz/member.php?userid=449
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=112817