+ Reply to Thread
Results 1 to 7 of 7

Store an action to remember later

Hybrid View

PFDave Store an action to remember... 11-10-2016, 10:16 AM
EssoExplJoe Re: Store an action to... 11-10-2016, 11:50 AM
PFDave Re: Store an action to... 11-10-2016, 11:57 AM
EssoExplJoe Re: Store an action to... 11-10-2016, 01:23 PM
PFDave Re: Store an action to... 11-11-2016, 04:39 AM
EssoExplJoe Re: Store an action to... 11-11-2016, 08:29 AM
PFDave Re: Store an action to... 11-11-2016, 09:33 AM
  1. #1
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Store an action to remember later

    Hi,

    Struggled to think of the best way to title this but hopefully I can explain clearly.

    I have a file where users are taken through steps by clicking on shapes on different sheets.

    There will be instances where a user can continue with the usual steps, however if they select NO to certain questions (or click a certain numbered shape) I want to be able to remember that for when they reach the final step where I will either display a MsgBox or direct them to another replica slide but with slightly different wording.

    Can this be done? Or what are peoples thoughts on this?

    Essentially the situation is to try to fix the issue yourself, but if you can't connect the system you need to in order to fix the issue, you carry on trouble shooting with someone on the phone and then once you reach the end you then need to follow some steps to get yourself to connect to the system for next time. (the reason this isn't done at the time, is because it takes 20 minutes to complete and the issue they are trying to fix is a higher priority so must be done first)

    Regards

    Dave

  2. #2
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    274

    Re: Store an action to remember later

    Store their answers to each step in an array of types:

    Type
    StepNo as integer
    Answer as string
    End type

  3. #3
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Store an action to remember later

    Thanks for the input Esso.

    Could you elaborate on this please with an example?

    Thanks again

  4. #4
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    274

    Re: Store an action to remember later

    Just dimension an array of the types;

    Type steprecord
    
    Answer as string
    End type
    
    dim steps() as steprecord
    redim steps(nosteps)
    After each step is completed, set the step answer in the array. You can save the array to a worksheet after each answer if you want under a username, etc..

  5. #5
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Store an action to remember later

    Thanks Esso,

    But could you provide a working example, I've never used type before or usernames in excel, but this sounds exactly like the kind of thing I would like to use.

    Thanks again

  6. #6
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    274

    Re: Store an action to remember later

    Define the user type:

    Type Questions
      User as string
      RecordNo as long
      SessionDate As Date
      Answers() As String
    End Type
    When the user restarts a session, get his user name and date of original session then get his answer record:

    Function Get_AnswerRecord(User As String, sessiondate As Date) As Questions
    'When user logs on, retrieve the answer record from the User's last session
      'assumse answer records are stored in a worksheet with:
      '   column A as the user
      '   column B as the session date
      '   answers in remaining columns
    'Returns record of user answers or user = "" if user and date not found in worksheet records
      
      Dim row As Long, col As Long, lastrow As Long, lastcol As Long, record As Long
      Dim sht As Worksheet, ans As Questions
      Set sht = Worksheets("records")
      'get last used row in worksheet
      lastrow = sht.Cells(sht.Rows.count, 1).End(xlUp).row
      row = 1: record = 0
      'Find the row for the User and session date
      Do While row <= lastrow
        If User = sht.Cells(row, 1) And sessiondate = sht.Cells(row, 2) Then
          record = row
          Exit Do
        End If
        row = row + 1
      Loop
      'Return user as "" if not found
      If record = 0 Then Get_AnswerRecord.User = "": Exit Function
      'fill in question structure
      ans.User = User
      ans.RecordNo = record
      ans.sessiondate = sessiondate
      lastcol = sht.Cells(record, Columns.count).End(xlToLeft).Column
      ReDim ans.Answers(lastcol - 2)
      col = 3
      Do While col <= lastcol
        ans.Answers(col - 3) = sht.Range(Cells(record, col))
        col = col + 1
      Loop
      Get_AnswerRecord = ans
    End Function
    Update the answer record each time the user answers a question;

    Sub UpdateAnswers(User As Questions, questionindex As Integer, answer As String)
    'Save answers to to a worksheet
      Dim record As Long, i As Long
      Dim sht As Worksheet
      Set sht = Worksheets("records")
      If User.RecordNo <= 0 Then record = 1 Else record = User.RecordNo
      sht.Cells(record, 1) = User.User
      sht.Cells(record, 2) = User.sessiondate
      If questionindex > UBound(User.Answers) Then ReDim Preserve User.Answers(questionindex)
      User.Answers(questionindex) = answer
      i = 1
      Do While i <= UBound(User.Answers)
        sht.Cells(record, i + 3) = User.Answers(i)
        i = i + 1
      Loop
    End Sub
    This will give you an idea of how to use user defined types.

  7. #7
    Valued Forum Contributor PFDave's Avatar
    Join Date
    05-17-2012
    Location
    Milton Keynes, England
    MS-Off Ver
    Excel 2013
    Posts
    1,067

    Re: Store an action to remember later

    Thanks Esso,

    give me something to work with for sure.

+ 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] Formula to create store by store inventory transfers
    By DamianTaylor in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-08-2016, 08:37 AM
  2. Replies: 3
    Last Post: 02-28-2016, 10:51 AM
  3. [SOLVED] Dynamic Changing Data, Based on Criteria Store in Array, Sum array and store in Cell
    By penbeacho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2015, 10:31 AM
  4. My Action Tracker Keeps placing my competed action rows on sheet2 in the same place.
    By billybong33 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2014, 04:01 PM
  5. Trying to remember...
    By neddyseagoon in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 08-29-2012, 09:20 AM
  6. If column A completely empty, one action; if not, another action?
    By StargateFanFromWork in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-15-2006, 04:15 PM
  7. I can't remember how to...
    By ForSale in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2005, 12:26 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