Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Expanding Range in Formula? | Excel Discussion (Misc queries) | |||
Expanding a Range Automatically | Excel Discussion (Misc queries) | |||
Expanding a range | Excel Programming | |||
Expanding ranges after sort??? | Excel Programming | |||
Named range not expanding with insertions after sort?? | Excel Programming |