+ Reply to Thread
Results 1 to 8 of 8

put Text box value into 1st empty space in colum

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    put Text box value into 1st empty space in colum

    YAH im stuck again.

    Got this
    Private Sub PicName_Form_Click()
    
    If PicName_textbox.Text = "" Or Decription_textbox.Text = "" Then MsgBox "Please Enter Picture Name & Short Dicription"
    ''BOTH TEXT PRESENT "NEXT STEEP"
    ''''''''''''''''''''''''''''''''''''''''''''''''
    'if PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then (A1).Value = "M³"
    ''''''''''''''''''''''''''''''''''''''''''''''''
    If PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then MsgBox "Photo Has Been Entered Corectly"
    If PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then Unload Me
    
    End Sub
    Trying to get the value's from PicName_textbox and Decription_textbox and enter the value for PicName_textbox into the 1st empty cell in colum A and Decription_textbox nto the 1st empty cell in colum B.

    Though i only want them transphered if both PicName_textbox and Decription_textbox

    Thank's Again.
    Last edited by D_Rennie; 06-04-2009 at 07:57 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: put Text box value into 1st empty space in colum

    Try
    Dim NextRw as long
    
    With Sheet1 '<-change this
    NextRw = .Cells(.rows.Count,1).End(xlUp).Row +1
    .Cells(NextRw,1).Value= PicName_textbox
    .Cells(NextRw,2).Value=ecription_textbox .Value
    End With
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: put Text box value into 1st empty space in colum

    cheers royuk you got me started there.

    though the code is writen over each time the macro runs.

    Would you please look at the example workbook. other thing is the userform dosent run close when run withen Macro1. You may see others as well.

    Thanks again roy.
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: put Text box value into 1st empty space in colum

    Trythis amended code
    
    
    Private Sub PicName_Form_Click()
    
        Dim NextRw As Long
    
    
        '''''''''''''''''''''''''''''''''''''''''''''''''''''
        If PicName_textbox.Text = "" Or Decription_textbox.Text = "" Then MsgBox _
           "Please Enter Picture Name & Short Dicription"
        ''BOTH TEXT PRESENT "NEXT STEEP"
        ''''''''''''''''''''''''''''''''''''''''''''''''
        'if PicName_txtbox.Text <> "" And Decription_textbox.Text <> "" Then (A1).Value = "M³"
        ''''''''''''''''''''''''''''''''''''''''''''''''
    
        If PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then MsgBox _
           "Photo Has Been Entered Corectly"
        If PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then Unload Me
        With Sheet1    '<-change this
            NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
            .Cells(NextRw, 3).Value = PicName_textbox
            .Cells(NextRw, 4).Value = Decription_textbox.Value
        End With
    End Sub

  5. #5
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: put Text box value into 1st empty space in colum

    Private Sub PicName_Form_Click()
    Application.ScreenUpdating = False
        Dim NextRw As Long
        If PicName_textbox.Text = "" Or Decription_textbox.Text = "" Then MsgBox _
           "Please Enter Picture Name & Short Dicription"
        With Sheet1    '<-change this
            NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
            .Cells(NextRw, 12).Value = PicName_textbox
            .Cells(NextRw, 13).Value = Decription_textbox.Value
        End With
        
    Dim ans As Integer
    If PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then ans = MsgBox _
    ("Would You Like To Add Another Picture?", vbYesNo)
    Select Case ans
    Case vbYes
    'Run [Macro1]
    Unload Me
    Case vbNo
    If PicName_textbox.Text <> "" And Decription_textbox.Text <> "" Then Unload Me
    End Select
    End Sub
    The code still dosent look to see if the cells have an entry. so textboxs overwrite the cell information. When it need to drop down a line.


    Thanks.
    Last edited by D_Rennie; 06-03-2009 at 03:41 PM. Reason: Edited Code

  6. #6
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: put Text box value into 1st empty space in colum

    bumping thread

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: put Text box value into 1st empty space in colum

    The code that I posted finds the next empty cell in Column A, it has to be empty so it cannot overwrite contents.

  8. #8
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: put Text box value into 1st empty space in colum

    Sorry RoyUK I think i understand it better now.
    The Code You gave me
            NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
            .Cells(NextRw, 3).Value = PicName_textbox
            .Cells(NextRw, 4).Value = Decription_textbox.Value
    Then I tryed To modifiy it to use diffrent cells.
            NextRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
            .Cells(NextRw, 12).Value = PicName_textbox
            .Cells(NextRw, 13).Value = Decription_textbox.Value

    now i understand the code

            NextRw = .Cells(.Rows.Count, 12*REFERANCE TO SEARCH*).End(xlUp).Row + 1
            .Cells(NextRw, 12*COLUM TO INSERT DATA).Value = PicName_textbox
            .Cells(NextRw, 13).Value = Decription_textbox.Value
    THANKS AGAIN.

    Sorry for not seeing it. Hope you dont get sick of me

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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