LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default non-expanding range (updated/simplified)

I was trying to figure out how to place the value of RawName into a single
cell at the end of the 'old' range; I managed to get TempRange referring to
the right range, but not (by default) a single cell [I'm used to notation
like range("A1").value = z]- so the code you indicate was my attempt just to
get the correct value into the cell. It might also work to say
TempRange.value = Rawname, but I kind of came at this sideways, and didn't
want to mess with pieces of code that were working unless I knew what I was
doing... <vbg
Thanks,
Keith

"Dave Peterson" wrote in message
...
I don't quite understand what you're doing with that last loop.

Dim MyCell As Range
For Each MyCell In TempRange
MyCell.Value = RawName
Next


But after you've added more to your list, you'll want to have the code
refresh
that range object.

I think...

rng.Offset(rng.Rows.Count, 0).Resize(1, 1).value = Rawname
'update rng
Set rng = ThisWorkbook.Names("Prescreenlist").RefersToRange



Keith wrote:

Thanks to Dave for fixing problem #2. I'm still struggling with how to
get
the named auto-expanding range to update after each loop. Interestingly,
when I added in another Set statement right before the line that I don't
believe was updating, it updated on the first loop through but not the
second. The first name was added on the first available cell, the second
name was added in the next available cell, then all subsequent names was
copied over the second name, never incrementing to the next cell.

I'm thinking maybe the code that selects the cell right after the range
isn't doing what I think it should do, but then I don't know why the
first
and second names actually go where they are supposed to go...

Many thanks,
Keith

Named range:
=OFFSET(AllApplicants!$A$11,0,0,COUNTA(AllApplican ts!$A$11:$A$14),1)

Relevant code (called from a worksheet button):

Private Sub cmdLoadNames_Click()

Dim rng As Range, TempRng As Range, sVal As String, res As Variant,
res2
As Variant
Set rng = ThisWorkbook.Names("Prescreenlist").RefersToRange 'the
names
that have already been transferred to sheet13

RawID = Val(Trim(Sheet14.Range("A1").Value))

For I = 2 To 65000
'Check each line for a new name
RawName = Trim(Sheet14.Range("A" & CStr(I)).Value)
'Check to make sure it is a real name, not just an extra line
If Len(RawName) 4 Then
'Check to see if the name is already on the list
res = Application.Match(RawName, rng, 0)
'If no match was found
If IsError(res) Then
'add the name to the list

'updates from named range to try to get correct rows.count
Set rng = ThisWorkbook.Names("Prescreenlist").RefersToRange
'tries to get the next (empty) cell after the current range
to
paste in the new name
Set TempRange = rng.Offset(rng.Rows.Count, 0).Resize(1,
1).Cells
' = Rawname
TempRow = rng.Offset(rng.Rows.Count, 0).Resize(1, 1).Row
'paste the value in the open cell
Dim MyCell As Range
For Each MyCell In TempRange
MyCell.Value = RawName
Next
End If
Else
Exit For 'exit loop b/c end of names list
End If
Next

End Sub


--

Dave Peterson



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expanding Range in Formula? John Sofillas Excel Discussion (Misc queries) 4 August 6th 09 01:26 PM
Expanding a Range Automatically Rob E Excel Discussion (Misc queries) 6 January 25th 08 05:57 AM
Expanding a range Oldjay Excel Programming 2 November 10th 06 06:08 PM
Expanding ranges after sort??? Simon Lloyd[_670_] Excel Programming 2 January 1st 06 05:45 PM
Named range not expanding with insertions after sort?? Simon Lloyd[_663_] Excel Programming 2 November 29th 05 08:23 PM


All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"