View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
david shapiro david shapiro is offline
external usenet poster
 
Posts: 23
Default pulling data from an excel workbook


Dave,

Thanks for the VB code for extracting data from worksheets by color.

Rather than checking the entire worksheet cell by cell for colored
cells, I`m thinking it might be easier if the programme just checks the
second column of every row in the worksheet.

If it is red, then extract the entire row of cells of data and list all
the rows in the new worksheet. This would be done for all of the
worksheets in the workbook. So the new worksheet would contain all the
red rows from all the worksheets in the workbook.

All of rows in the worksheets have a standard number of columns (from
columns A to AB on the excel sheet). (If possible, it would be good if
the computer flagged when a worksheet did not have the standard A to AB
number of columns.)

How can I find out the right number for red in my color index?

I`ve also created the following code for preparing each of the
worksheets for the extraction process:

Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("C1").Select
Selection.Copy
Range("A1").Select
ActiveSheet.Paste
Columns("A:C").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Application.CutCopyMode = False
Selection.FormulaR1C1 = "=R[-1]C"
End Sub

Would it be possible to alter the code so that it runs this procedure on
every worksheet in the workbook? And then add the extraction procedure
(which creates the new data sheet and extract the rows of data by color)
after this.

Overall, this is what the VB does:

1) It prepares the worksheets for the extraction process (this is done
for each worksheet in the workbook): the procedure for each worksheet
is above.

2) When all worksheets prepared, a new empty data sheet is created.

3) Search through each row of the worksheet for every row where the
second column is red. If column 2 of the row is red, extract the whole
row of cells and list in the new data sheet. Do procedure for all
worksheets.

4) New data sheet contains all rows in worksheets in workbook for which
the second column is red.

Hope the description isn`t too complicated. Thanks very much.

Dave

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!