Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2005, 05:34 PM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with VBA Code

I have an excel workbook that I use to track inspection items. There are several sheets, each with a list of questions for the user to answer. If the user answers "NO" to any question, they will enter an explanation (Text) in columns E, F, & G. If the user answers "YES" to any of the questions, no text is required.

I want to pull all of the text that is entered into a separate list in this workbook. I want all of the empty rows skipped, and only the text that appears in columns E, F, & G to show up in this list.

Can anyone help me with the code?

 
Old April 22nd, 2005, 06:50 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is some code that you can amend. It shows the basic principles.
Code:
'====================================================
'- TRANSFER DATA FROM A SHEET TO MASTER
'- DEPENDING ON A CELL IN THE ROW
'- uses an x in column A
'====================================================
Sub DataToSummary()
    Dim FromSheet As Worksheet
    Dim FromRow As Long
    Dim LastRow As Long
    '-
    Dim ToSheet As Worksheet
    Dim ToRow As Long
    '-------------------------------------------------
    Application.Calculation = xlCalculationManual
    Set ToSheet = ActiveWorkbook.Worksheets("Summary")
    '- find next empty Summary row
    ToRow = ToSheet.Range("A65536").End(xlUp).Row + 1
    '-------------------------------------------------
    Set FromSheet = ActiveSheet
    LastRow = FromSheet.Range("A65536").End(xlUp).Row
    '-------------------------------------------------
    '- loop through rows
    For FromRow = 1 To LastRow
        If FromSheet.Cells(FromRow, 1).Value = "x" Then
            ToSheet.Cells(ToRow, 1).Value = _
                    FromSheet.Cells(FromRow, 1).Value
            ToSheet.Cells(ToRow, 2).Value = _
                    FromSheet.Cells(FromRow, 2).Value
            ToSheet.Cells(ToRow, 3).Value = _
                    FromSheet.Cells(FromRow, 3).Value
            ToRow = ToRow + 1
        End If
    Next
    '-------------------------------------------------
    MsgBox ("Done")
    Application.Calculation = xlCalculationAutomatic
End Sub
'-----------------------------------------------------
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.





Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code D0MiN0 Access VBA 2 March 31st, 2008 03:55 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
vba code need in.ssuresh Excel VBA 2 November 29th, 2005 08:40 PM
vba code in.ssuresh Excel VBA 1 November 28th, 2005 05:10 AM
VBA code desprate Access VBA 7 April 12th, 2005 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.