Advertisement

09.14.2007 at 02:24AM PDT, ID: 22828387
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

2nd variable needed and can't think of anything to use to do it... T-T

Asked by touyets in VB Script, Microsoft Excel Spreadsheet Software

Tags: , , , , ,

Hi again,
i'm starting to adore this website :)

Ok, i have a VBA coding that finds an entry, saves it, input another value at that same place and then inputs the saved value in the first empty cell in Column A (2 other values ar esaved and entred in B and C). Then a MessageBox opens and I want it to say that the saved entry was inputed at a certain value (cell value in Column D of the line of the first empty cell - iRow and that's sorted) but here's the problem: then I also want it to say that the new entry (which replaced the saved value after having found it in the database) was inputed at a certain value (cell value in Column D of the line of the original value that was looked for using VBA coding at the beggining)

Complex to explain but tried it as good as I could...

teh problem lies at the end of the coding.

i tried to put a x = SelectionRow after the search string but that doesn't work. it gives me the value of the cell in column D of the row selected when opening Excel....

250 points for this one...

Here's the code:
--------------------------------------------------------
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")

'check for a Reference number
If Trim(Me.RefReplaceNew.Value) = "POBF" Then
  Me.RefReplaceNew.SetFocus
  MsgBox "Please enter a Reference number for the new job"
  Exit Sub
End If

'check for a Title
If Trim(Me.TitleReplaceNew.Value) = "" Then
  Me.TitleReplaceNew.SetFocus
  MsgBox "Please enter a Title"
  Exit Sub
End If

'check for a Category
If Trim(Me.CategoryReplaceNew.Value) = "" Then
  Me.CategoryReplaceNew.SetFocus
  MsgBox "Please enter a Category"
  Exit Sub
End If

'check for a Reference number
If Trim(Me.RefReplaceOld.Value) = "POBF" Then
  Me.RefReplaceOld.SetFocus
  MsgBox "Please enter a Reference number for the old job"
  Exit Sub
End If

'Find old job
Set cel = Range("A:A").Find(RefReplaceOld, LookIn:=xlValues, LookAt:=xlWhole)
If Not cel Is Nothing Then
    With cel
        RefReplaceSave = .Value
        TitleReplaceSave = .Offset(0, 1).Value
        CategoryReplaceSave = .Offset(0, 2).Value

        .Value = RefReplaceNew
        .Offset(0, 1).Value = TitleReplaceNew
        .Offset(0, 2).Value = CategoryReplaceNew
    'find  first empty row in database
        iRow = FirstEmptyRowInA(ws)
    'copy the data to the database
        ws.Cells(iRow, 1).Value = RefReplaceSave
        ws.Cells(iRow, 2).Value = TitleReplaceSave
        ws.Cells(iRow, 3).Value = CategoryReplaceSave
    'Autofit Column B
        Columns("B:B").EntireColumn.AutoFit
    'Autofit Column C
        Columns("C:C").EntireColumn.AutoFit
    'clear the data
        Me.RefReplaceNew.Value = "POBF"
        Me.TitleReplaceNew.Value = ""
        Me.CategoryReplaceNew.Value = ""
        Me.RefReplaceOld.Value = "POBF"
    'Message box
    MsgBox "The number assigned to the New entry is: " & Sheets("Database").Range("D" & x) & " and the old entry is now in batch: " & Sheets("Database").Range("D" & iRow)
    End With
Else
    MsgBox "Reference # " & RefReplaceOld & " not found!", vbInformation
End If


End Sub

Private Sub CommandButton2_Click()
'Close that form

Me.Hide
frmHome.Show
End Sub

Function FirstEmptyRowInA(wks As Worksheet)
   With wks
      If Len(.Cells(1, "A").Formula) = 0 Then
         FirstEmptyRowInA = 1
      ElseIf Len(.Cells(2, "A").Formula) = 0 Then
         FirstEmptyRowInA = 2
      Else
         FirstEmptyRowInA = .Cells(1, "A").End(xlDown).Row + 1
      End If
   End With
End FunctionStart Free Trial
[+][-]09.14.2007 at 02:47AM PDT, ID: 19890028

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Microsoft Excel Spreadsheet Software
Tags: Microsoft, Excel, 2003, VBA, MS Excel, VBA Coding
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.14.2007 at 02:52AM PDT, ID: 19890058

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.14.2007 at 03:02AM PDT, ID: 19890103

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628