+ Reply to Thread
Results 1 to 3 of 3

Insertion mark sheet in VBA

  1. #1
    Registered User
    Join Date
    03-12-2016
    Location
    Serbia
    MS-Off Ver
    2010
    Posts
    6

    Insertion mark sheet in VBA

    UserForm form a single Excel database. "He did," I module, as instructed, to fill one of the table - and it works ... but I'm the VBA "real" table on Sheet-in where there is a button for beginning the forms.
    Where, in the VBA code, the need to specify the path to the target table - or a sheet?
    Button to start the UserForm on my Sheet7, a table in which the data should be entered on Sheet1 (name Sheet is "Podaci").

    UserForm code is:

    Option Explicit

    Private Sub CommandButton1_Click()
    EditAdd
    End Sub

    Private Sub CommandButton2_Click()
    ClearForm
    End Sub

    Private Sub CommandButton3_Click()
    Unload Me
    End Sub

    Private Sub TextBox1_Change()
    GetData
    End Sub

    Private Sub UserForm_Initialize()

    TextBox1.SetFocus

    End Sub



    Modul code is:

    Dim id As Integer, i As Integer, j As Integer, flag As Boolean
    Sub GetData()

    If IsNumeric(UserForm1.TextBox1.Value) Then
    flag = False
    i = 0
    id = UserForm1.TextBox1.Value

    Do While Cells(i + 1, 1).Value <> ""

    If Cells(i + 1, 1).Value = id Then
    flag = True
    For j = 2 To 10
    UserForm1.Controls("TextBox" & j).Value = Cells(i + 1, j).Value
    Next j
    End If

    i = i + 1

    Loop

    If flag = False Then
    For j = 2 To 10
    UserForm1.Controls("TextBox" & j).Value = ""
    Next j
    End If

    Else
    ClearForm
    End If

    End Sub
    Sub ClearForm()

    For j = 1 To 10
    UserForm1.Controls("TextBox" & j).Value = ""
    Next j

    End Sub
    Sub EditAdd()

    Dim emptyRow As Long

    If UserForm1.TextBox1.Value <> "" Then
    flag = False
    i = 0
    id = UserForm1.TextBox1.Value
    emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1

    Do While Cells(i + 1, 1).Value <> ""

    If Cells(i + 1, 1).Value = id Then
    flag = True
    For j = 2 To 10
    Cells(i + 1, j).Value = UserForm1.Controls("TextBox" & j).Value
    Next j
    End If

    i = i + 1

    Loop

    If flag = False Then
    For j = 1 To 10
    Cells(emptyRow, j).Value = UserForm1.Controls("TextBox" & j).Value
    Next j
    End If

    End If

    End Sub


    Is it, perhaps, the rule that form (as well as a button that launches it) is the same "Sheet" are where is the table?
    I used the instructions: http://www.excel-easy.com/vba/exampl...-userform.html

  2. #2
    Registered User
    Join Date
    03-12-2016
    Location
    Serbia
    MS-Off Ver
    2010
    Posts
    6

    Re: Insertion mark sheet in VBA

    This is not resolved, I have to open a new topic

  3. #3
    Registered User
    Join Date
    03-12-2016
    Location
    Serbia
    MS-Off Ver
    2010
    Posts
    6

    Re: Insertion mark sheet in VBA

    Sorry for the mistakes and I've marked as "solved" - and is not. The question I moved to the following address: http://www.excelforum.com/showthread...t=#post4353612

+ 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. Protected sheet how do I allow row insertion on specific rows
    By ArnolddG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2014, 08:23 AM
  2. [SOLVED] Allow insertion of row in protected sheet
    By Scofield24 in forum Excel General
    Replies: 5
    Last Post: 09-07-2013, 06:48 AM
  3. Automatic insertion of new sheet
    By ubad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2013, 09:52 AM
  4. Automatic insertion of new sheet
    By ubad in forum Excel General
    Replies: 2
    Last Post: 07-07-2013, 01:32 AM
  5. Sum cells across different sheet with protect again row insertion
    By hugolm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-24-2012, 08:13 AM
  6. Mark data from one sheet to another,and then mark dublicate
    By minotauro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2012, 07:58 AM
  7. Dynamic Formulas and Sheet Insertion
    By nschmoyer in forum Excel General
    Replies: 4
    Last Post: 04-28-2009, 05:53 PM
  8. Sheet Protection & Insertion.
    By bnnaga in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2006, 10:25 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