Consulting

Results 1 to 15 of 15

Thread: Solved: Data Form Assistance

  1. #1
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location

    Solved: Data Form Assistance

    On a single worksheet, I have 5 categories that contain 5 columns of "input data". In between each category is an empty column shaded gray just to provide some separation for viewing ease.

    What I'm trying to do is have a data form for each category, which works if I click on the cells in a particular category and go to "Data" and select "Form".

    I'm trying to automate the process where I can click a button and the data form for that category comes up. I tried recording a macro that would select the cells first and then bring up the data form for that category but it doesn't seem to work - it always brings up the data form for the first category.

    Should I just create a user form for each and go from there or is there a way to make what I'm trying to do work? Or perhaps there is a more efficient way to achieve this result that I'm simply not aware of.

    ---
    Single Worksheet - simulated
    ---
    Cars
    A1 Make
    B1 Model
    C1 Color

    D1 (empty column)

    Trucks
    E1 Make
    F1 Model
    G1 Color

    H1 (empty column)

    Motorcycles
    I1 Make
    J1 Model
    K1 Color

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    It would really help if you could post your workbook. Remove any personal info and use manage attachments after you click on post reply. I am afraid I don't understand the layout from your description and it would be easier if I could see it.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Should Cars be A1, A2 & A3 etc.?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    I have attached a sample...I don't have the actual worksheet available, but it really isn't needed.

    Now, within the worksheet...I can click any cell in the next avail row in the different categories and then click data + form and get a different form.

    I'm just trying to automate the process and was wondering if there is a macro to do it or if I should just create all new user forms...given that there are minimal columns, I'm trying to minimize the number of sheets and/or userforms.

    Hope this helps clear up what I'm trying to do.

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    ShowDataForm Method Fails If Data Can't Be Found
    http://support.microsoft.com/default.aspx?id=110462


    Try this from any cell within the category.
    [VBA]
    Sub ShowDataForm()
    ActiveWorkbook.Names.Add Name:="Database", _
    RefersTo:="=" & ActiveSheet.Name & "!" & Cells(1, ActiveCell.Column).CurrentRegion.Address
    ActiveSheet.ShowDataForm
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    Like a champ...

    You've done it again...thanks a million.


  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    HTH.
    How about adding your country and flags to your profile. It's nice to see where other members are from.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location

    Userform way ...

    Using a userform and doubleclick event. Doubleclick in A, E or I starting from row 1 to see what happens. Perhaps it will be usefull.

    Charlize

  9. #9
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    hey...that's pretty slick too...I'm sure I can put that to use. Thanks!

  10. #10
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    Question about Data Forms...

    I have a piece of code that changes all text typed into a cell to shift to upper case...however...if I call up a data form and type it in lower case then close the form...the text remains lower case.

    Is there anyway to fix or work around this...?

  11. #11
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    [VBA]Private Sub CommandButton1_Click()
    ActiveCell.Value = UCase(Me.TextBox1.Value)
    End Sub[/VBA]

  12. #12
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Charlize,
    A Dataform is not the same as a Userform, so no command button involved. Entering the data on a dataform is not triggering a Worksheet Change event, which is what I guess RTTS is using. Still thinking!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  13. #13
    VBAX Regular rrtts's Avatar
    Joined
    Sep 2006
    Posts
    61
    Location
    @ Charlize - MD is right...but I appreciate the attempt at helping...

    @ MD - I assume that means that you are able to recreate what I have described...

    Here is the code I am using if it helps...it works very well except for the dataform issue...(I'm not the author of it and take no credit for creating it - but whoever did...thanks).

    [vba]
    Private Sub Worksheet_Change(ByVal Target As Range)
    ''''''''''''''''''''''''''''''''''''''''''''
    'Forces all text to UPPER case
    ''''''''''''''''''''''''''''''''''''''''''''
    'If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
    On Error Resume Next
    Application.EnableEvents = False
    Target = UCase(Target)
    Application.EnableEvents = True
    On Error GoTo 0
    End Sub
    [/vba]

  14. #14
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I guessed your code! I've posted a new question with a pointer here for some fresh input.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  15. #15
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    You could try this one. Macro to show dataform and after input do the necessary stuff. ???
    [vba]Sub Input_Form()
    ' content of column A to change in uppercase
    Dim content As String
    ' number of rows
    Dim lrow As Long
    ' a loop counter
    Dim counter As Long
    ' the rowposition
    Dim pos As Long
    ' setting the alerts off
    Application.DisplayAlerts = False
    ' headtitles in A1:B2
    Sheets(1).Range("A1:B1").Select
    ' show the dataform
    Sheets(1).ShowDataForm
    ' setting the alerts back on
    Application.DisplayAlerts = True
    ' counting number of rows with something in A
    ' Column A must still be filled in.
    lrow = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
    ' if more than one row, we must do something after closing
    ' the dataform
    If lrow <> 1 Then
    pos = 2
    For counter = 2 To lrow
    content = Range("A" & pos).Value
    Range("A" & pos).Value = UCase(content)
    pos = pos + 1
    Next counter
    End If
    End Sub[/vba]
    Charlize

Posting Permissions

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