Creating a report

O177812

Board Regular
Joined
Apr 16, 2015
Messages
82
Office Version
  1. 365
  2. 2021
I am trying to create a list using my data.

I have 26 columns and some of them contain data and some of them contain Error.

I want to write a formula that will copy the Item number (Column A) and then will list the header for each error by item.

See below:

ITEMTITLEFIXENDERSTAINFINISH
14620ERRORPINERRORREDRED
15712
GLOBAL TURNKITERRORPLASTICGREENGREEN
18921MEGA KITPINMETALBLUEBLUE

<tbody>
</tbody>


I would like my report to look like this

________________


14620:

TITLE
ENDER

15712:

FIX

18921:

NO ERRORS

_________________


This data could appear at the end of each line until I figure out how to write VBA so that it will open up a word document and copy the information on a different sheet.

Thanks for the help.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Code:
Public Sub BuildRpt()
Dim colFlds As New Collection
Dim c As Long
Dim shtData As Worksheet, shtRpt As Worksheet
Dim vItm
Dim bFound As Boolean


  'start at top of report get fld names
Set shtData = ActiveSheet
Range("A1").Select
While ActiveCell.Value <> ""    'get headers
   colFlds.Add ActiveCell.Value
   ActiveCell.Offset(0, 1).Select  'next col
Wend

'scan data, find the errors
Sheets.Add
Set shtRpt = ActiveSheet
shtData.Activate
Range("A2").Select
While ActiveCell.Value <> ""    'scan all the data for error
   For c = 0 To colFlds.Count - 1
      vItm = ActiveCell.Value
      If ActiveCell.Offset(0, c).Value = "ERROR" Then
         If Not bFound Then
            shtRpt.Activate
            ActiveCell.Value = vItm
            shtData.Activate
         End If
         
          bFound = True
         shtRpt.Activate
         ActiveCell.Offset(1, 0).Select  'next row
         ActiveCell.Value = colFlds(c)
         shtData.Activate
      End If
   Next
   If bFound Then
      shtRpt.Activate
      ActiveCell.Offset(1, 0).Select  'next row
      shtData.Activate
   End If
   
   ActiveCell.Offset(1, 0).Select  'next row
   bFound = False
Wend

  'memory cleaner
Set colFlds = Nothing
Set shtData = Nothing
Set shtRpt = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,478
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top