Advertisement

07.02.2008 at 03:47PM PDT, ID: 23535385
[x]
Attachment Details

Create VBA Code inside Excel using VBA

Asked by OB1Canobie in Microsoft Excel Spreadsheet Software, Visual Basic Programming, VB Script

Tags: VBA, Internet Explorer 6.0

I have an Access Database program that is creating Excel Workbooks, however, I have hidden sheets that require some VBA code.  I need a way to create the VBA code inside each Excel Workbook created using VBA code.  I have attached the code that needs to go into each workbook.  Thanks.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 41 Then                                          'THIS IS THE STATUS COLUMN
    Dim lstrow As Long
   
    With Sheets("hidden")
   
        lstrow = .Range("A65536").End(xlUp).Row
        .Cells(lstrow + 1, 1) = ActiveSheet.Cells(Target.Row, 1)    'THIS IS THE ACCOUNT NUMBER COLUMN
        .Cells(lstrow + 1, 2) = ActiveSheet.Cells(Target.Row, 41)   'THIS IS THE STATUS COLUMN
        .Cells(lstrow + 1, 3) = Date                                'THIS IS AUTOMATED RECORD LOGGING
        .Cells(lstrow + 1, 4) = Time                                'THIS IS AUTOMATED RECORD LOGGING
   
    End With
End If

If Target.Column = 41 Then                                                  '

    With Sheets("hidden")
        lstrow = .Range("A65536").End(xlUp).Row
        For i = 2 To lstrow
            If .Cells(i, 1) = ActiveSheet.Cells(Target.Row, 1) And .Cells(i, 2) = ActiveSheet.Cells(Target.Row, 41) Then
                .Cells(i, 5) = ActiveSheet.Cells(Target.Row, 42)
                Exit Sub
            End If
        Next
        .Cells(lstrow + 1, 1) = ActiveSheet.Cells(Target.Row, 1)    'THIS IS THE ACCOUNT NUMBER COLUMN
        .Cells(lstrow + 1, 2) = ActiveSheet.Cells(Target.Row, 41)   'THIS IS THE STATUS COLUMN
        .Cells(lstrow + 1, 3) = Date                                'THIS IS AUTOMATED RECORD LOGGING
        .Cells(lstrow + 1, 4) = Time                                'THIS IS AUTOMATED RECORD LOGGING
        .Cells(lstrow + 1, 5) = ActiveSheet.Cells(Target.Row, 42)   'THIS IS COMMNET LINE
    End With

End If

End SubStart Free Trial
[+][-]07.02.2008 at 03:59PM PDT, ID: 21921567

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.

 
[+][-]07.02.2008 at 03:59PM PDT, ID: 21921569

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.

 
[+][-]07.02.2008 at 04:01PM PDT, ID: 21921579

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.

 
[+][-]07.02.2008 at 04:03PM PDT, ID: 21921588

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.

 
[+][-]07.02.2008 at 04:15PM PDT, ID: 21921639

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: Microsoft Excel Spreadsheet Software, Visual Basic Programming, VB Script
Tags: VBA, Internet Explorer 6.0
Sign Up Now!
Solution Provided By: nutsch
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.02.2008 at 04:54PM PDT, ID: 21921807

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.

 
[+][-]07.02.2008 at 05:10PM PDT, ID: 21921860

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.

 
[+][-]07.23.2008 at 07:43PM PDT, ID: 22075742

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.

 
[+][-]07.23.2008 at 07:51PM PDT, ID: 22075772

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.

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