+ Reply to Thread
Results 1 to 4 of 4

Insertion mark sheet in VBA

Hybrid View

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

    Insertion mark sheet in VBA

    Create UserForm 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
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Insertion mark sheet in VBA

    Welcome to the forum, miroslavp.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

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

    Re: Insertion mark sheet in VBA

    Sorry and thanks. I'll repeat the post with appropriate markings.

    Create UserForm 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?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Insertion mark sheet in VBA

    I'm sorry, I can't parse your question at all. Perhaps someone else can, or perhaps you could post your question in your native language in the non-English forum.

+ 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. [SOLVED] Insertion mark sheet in VBA
    By miroslavp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2016, 03:26 PM
  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. 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
  6. Dynamic Formulas and Sheet Insertion
    By nschmoyer in forum Excel General
    Replies: 4
    Last Post: 04-28-2009, 05:53 PM
  7. 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