selection of fields from Excel based on color and outputting the selected fields to new excel sheet

  • Thread starter Thread starter uday
  • Start date Start date
U

uday

i need to write a visual basic program to perform the analysis of Excel
price list to analyze the line and column headings and copy them along
with the prices into a sheet . the program should react to the colors as
shown .

selection of fields from Excel based on color and outputting the
selected fields to new excel sheet

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 
If you record a macro when you change the color, then you'll know what property
your code will have to inspect.

Then you can do things like:

Option Explicit
Sub testme01()
Dim myHeaderRng As Range
Dim myCell As Range
Dim RngToCopy As Range
Dim DestCell As Range

With ActiveSheet
Set myHeaderRng = .Range("a1:e1")
For Each myCell In myHeaderRng.Cells
If myCell.Interior.ColorIndex = 6 Then
Set RngToCopy _
= .Range(myCell, .Cells(.Rows.Count, myCell.Column).End(xlUp))
With Worksheets("Othersheetnamehere")
Set DestCell _
= .Cells(1, .Columns.Count).End(xlToLeft).Offset(0, 1)
End With
RngToCopy.Copy _
Destination:=DestCell
End If
Next myCell
End With

End Sub

Maybe this'll get you started.
 
Back
Top