View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steff_DK[_16_] Steff_DK[_16_] is offline
external usenet poster
 
Posts: 1
Default Naming a range with VBA...

Dim sNewname As String
sNewname = ""
Do While sNewname = ""
sNewname = InputBox("Enter initials for new person:")
If sNewname = "" Then iSvar = MsgBox("Do you want to quit?", vbYesNo)
If iSvar = vbYes Then
Exit Do
End If

Loop

Range("C2").CurrentRegion.Select

Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Activate
Loop
ActiveCell.Value = sNewname
Dim sAddr As String
sAddr = ActiveCell.Address

MsgBox sAddr
ActiveWorkbook.Names("ansvar").Delete
ActiveWorkbook.Names.Add Name:="ansvar", RefersTo:="=Lister!$c$1:"
sAddr

Range("C2").CurrentRegion.Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
_
DataOption1:=xlSortNorma

--
Message posted from http://www.ExcelForum.com