H
H.Schurch
Dear Experts
I have a range in a spreadsheet set up with a macro that concatenates the
row and column headings and copies the number (if it is >0) in the cell
where the column heading and row heading meet to a new worksheet. A bit like
looking up a street directory. Sometimes I have to change the criteria and
want only numbers copied that are >10. I know how to change the macro to do
this. I now have to copy numbers that are > than minus 1. Because some of
the cells in the range are empty it still concatenates the empty cells the
row and column headings and copies them to the worksheet. How do I change
the command in the macro so it leaves empty cells alone and does not copy
the row &column headings. It needs to be something like if value > -1 and
the cell <>"" Then?
Any help greatly appreciated. I am using Excel 97
Below is the code I am using.
Sub DomTkr734()
Dim MColHeadingValue, MRowHeadingValue, MRow, MCol, MVal
Windows("Dispatch Fuel Tanker Analysis.xls").Activate
Sheets("Dom Tkr").Select
Range("E4").Select
MRow = ActiveCell.Row
MCol = ActiveCell.Column
MRowHeadingValue = Cells(MRow, 1)
MColHeadingValue = Cells(1, MCol)
----------------------------------------------------------------------------
----
Do While MRowHeadingValue <> ""
Do While MColHeadingValue <> ""
MVal = Cells(MRow, MCol).Value
If MVal > 0 Then (What goes in here?????????)
Windows("TankeringSummary.xls").Activate
Sheets("Dom Summary").Select
Range("A65535").Select
Selection.End(xlUp).Select
Selection.Offset(1, 0).Select
Selection.Value = MRowHeadingValue & "/" & MColHeadingValue
Selection.Offset(0, 1).Value = MVal
Windows("Dispatch Fuel Tanker Analysis.xls").Activate
Sheets("Dom Tkr").Select
End If
Cells(MRow, MCol + 1).Select
MCol = ActiveCell.Column
MColHeadingValue = Cells(1, MCol)
Loop
MCol = 5
Cells(MRow + 1, MCol).Select
MRow = ActiveCell.Row
MRowHeadingValue = Cells(MRow, 1)
MColHeadingValue = Cells(1, MCol)
Loop
Windows("TankeringSummary.xls").Activate
Range("C1").Select
End Sub
I have a range in a spreadsheet set up with a macro that concatenates the
row and column headings and copies the number (if it is >0) in the cell
where the column heading and row heading meet to a new worksheet. A bit like
looking up a street directory. Sometimes I have to change the criteria and
want only numbers copied that are >10. I know how to change the macro to do
this. I now have to copy numbers that are > than minus 1. Because some of
the cells in the range are empty it still concatenates the empty cells the
row and column headings and copies them to the worksheet. How do I change
the command in the macro so it leaves empty cells alone and does not copy
the row &column headings. It needs to be something like if value > -1 and
the cell <>"" Then?
Any help greatly appreciated. I am using Excel 97
Below is the code I am using.
Sub DomTkr734()
Dim MColHeadingValue, MRowHeadingValue, MRow, MCol, MVal
Windows("Dispatch Fuel Tanker Analysis.xls").Activate
Sheets("Dom Tkr").Select
Range("E4").Select
MRow = ActiveCell.Row
MCol = ActiveCell.Column
MRowHeadingValue = Cells(MRow, 1)
MColHeadingValue = Cells(1, MCol)
----------------------------------------------------------------------------
----
Do While MRowHeadingValue <> ""
Do While MColHeadingValue <> ""
MVal = Cells(MRow, MCol).Value
If MVal > 0 Then (What goes in here?????????)
Windows("TankeringSummary.xls").Activate
Sheets("Dom Summary").Select
Range("A65535").Select
Selection.End(xlUp).Select
Selection.Offset(1, 0).Select
Selection.Value = MRowHeadingValue & "/" & MColHeadingValue
Selection.Offset(0, 1).Value = MVal
Windows("Dispatch Fuel Tanker Analysis.xls").Activate
Sheets("Dom Tkr").Select
End If
Cells(MRow, MCol + 1).Select
MCol = ActiveCell.Column
MColHeadingValue = Cells(1, MCol)
Loop
MCol = 5
Cells(MRow + 1, MCol).Select
MRow = ActiveCell.Row
MRowHeadingValue = Cells(MRow, 1)
MColHeadingValue = Cells(1, MCol)
Loop
Windows("TankeringSummary.xls").Activate
Range("C1").Select
End Sub