Results 1 to 2 of 2

input data and clear cells

Threaded View

  1. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: input data and clear cells

    This is the basic approach:
    Option Explicit
    
    Sub FormToDatabase()
    'Transfer data from specific cells on a form sheet to a database sheet
    
    Dim wsFORM As Worksheet, wsDATA As Worksheet, NR As Long
    
    Set wsFORM = Sheets("MyForm")
    Set wsDATA = Sheets("Database")
    
    NR = wsDATA.Range("A" & Rows.Count).End(xlUp).Row + 1
    
    With wsFORM
        wsDATA.Range("A" & NR).Value = .Range("A1").Value
        wsDATA.Range("B" & NR).Value = .Range("C10").Value
        wsDATA.Range("C" & NR).Value = .Range("E11").Value
        wsDATA.Range("D" & NR).Value = .Range("A12").Value
        wsDATA.Range("E" & NR).Value = .Range("C15").Value
        'etc, add more rows as needed
    
        'now clear all the cells used above to reset the form
        .Range("A1,C10,E11,A12,C15").ClearContents
    End With
    
    End Sub
    Last edited by JBeaucaire; 02-11-2013 at 02:44 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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