+ Reply to Thread
Results 1 to 2 of 2

Send data from userform to named range

Hybrid View

  1. #1
    Registered User
    Join Date
    04-03-2010
    Location
    Orlando, FL
    MS-Off Ver
    Office 365
    Posts
    94

    Send data from userform to named range

    Hi All, I have a userform that is used to collect something like 75 pieces of data, which are then sent to the main worksheet. I have code which then parses the data into 5 named ranges for import into an Access database. Code for transferring the data looks like this:
    '--------ClinicData--------
    ws.Cells(lRow, 1).Value = Format(Me.TxtTxID & (lRow - 2), "0")
    ws.Cells(lRow, 2).Value = Me.txtClinic
    ws.Cells(lRow, 3).Value = Me.txtSurgeon
    ws.Cells(lRow, 4).Value = Me.txtRep1
    ws.Cells(lRow, 5).Value = Me.txtRep2
    
    
    If Me.txtSN > 4 Then
        ws.Cells(lRow, 6).Value = Right(Me.txtSN, 4)
    Else: ws.Cells(lRow, 6).Value = Me.txtSN
    End If
    
    ws.Cells(lRow, 7).Value = Me.txtSW
    ws.Cells(lRow, 8).Value = Me.cboPhaco
    ws.Cells(lRow, 9).Value = Format(Me.txtDate, "dd-mmm-yyyy")
    Code to parse the data looks like this:
    Sub Name_Ranges()
    
    Sheets("Export").Unprotect Password:="CataractData"
    ThisWorkbook.Names.Add Name:="aClinicData", _
        RefersTo:=Sheets("Export").Range("A1:I" & Sheets("Export").Range("A65535").End(xlUp).Row)
    
    End Sub
    So far this is working well. So well, in fact so well that Management now wants more data in the form. This will be a lot of work, because the new data will not be at the end of the list of data, but interspersed within the row. Therefore, if I add two items in the middle, then all of the other cell references will have to be changed by two as well.

    I'm curious if it's possible that I reference the named range when inserting the data - that way at least when I am writing the code I can keep it straight in my mind that things are going in the right places!

    By the way, this was originally posted here: http://www.mrexcel.com/forum/excel-q...ml#post4277811 ... no luck there...

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Send data from userform to named range

    Hi wpryan,
    maybe so
    Sub Name_Ranges()
    Sheets("Export").Unprotect Password:="CataractData"
    ThisWorkbook.Names.Add Name:="aClinicData", _
        RefersTo:=Sheets("Export").Range("A1").CurrentRegion
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Send a Named Range as an Array to webservices and return results
    By wingnut2dot0 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2015, 03:48 AM
  2. Replies: 0
    Last Post: 02-27-2014, 04:43 PM
  3. Named Range reference changes when I send file to some users
    By fb7894 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-02-2013, 08:02 AM
  4. [SOLVED] Copy Data loaded via Userform to a worksheet named in 1 field of the Userform
    By audax48 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 01:44 PM
  5. Insert UserForm Data in Named Range
    By Patchworks in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2009, 10:50 PM
  6. transfer data from one named range to another via a userform
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-09-2009, 05:32 AM
  7. problem with userform show data from a named range
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2009, 06:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1