G
Guest
Hi All,
I have spent all weekend trying to debug what's wrong with my code. I find
the first empty cell and dorp the current date and the other data across
current row. The problem I have is when I click the calc button again, it
drops the date but placed the other data on other rows.
Below is my code. I tried evrything. Does the formatting affect the rest
of the code Offset. It must be simple that I miss it.
Any help is great ly appreciated. Thanks.
Sub RXWaterLog() ‘Macro to start at Column 1 Row 3 find empty cell and add
data
Dim Today
Today = Now ' Assign current system date and time.
Dim MyCellCell As Range
With Worksheets("ICON Data Log")
If IsEmpty(.Cells(3, 1)) Then
Set MyCellCell = .Cells(3, 1)
ElseIf IsEmpty(.Cells(3 + 1, 1)) Then
Set MyCellCell = .Cells(3 + 1, 1)
Else
Set MyCellCell = .Cells(3, 1).End(xlDown).Offset(1, 0)
End If
MyCellValue = Today
End With
'System Data
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = " Water"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Locked = True
Selection.FormulaHidden = False
Selection.FormulaHidden = False
'Chromium
'With Workheets("ICON Data Log")
ActiveCell.Offset(0, 1).Activate
ActiveCell.Formula = "=IF(OR('Reactor Water'!F12=""Cr"",'Reactor
Water'!F13=""Cr""),LOOKUP(""B"",'Reactor Water'!F12:F13:'Reactor
Water'!G12:G13),0)"
'End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
'.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Locked = True
Selection.FormulaHidden = False'
End Sub
Ligaya
I have spent all weekend trying to debug what's wrong with my code. I find
the first empty cell and dorp the current date and the other data across
current row. The problem I have is when I click the calc button again, it
drops the date but placed the other data on other rows.
Below is my code. I tried evrything. Does the formatting affect the rest
of the code Offset. It must be simple that I miss it.
Any help is great ly appreciated. Thanks.
Sub RXWaterLog() ‘Macro to start at Column 1 Row 3 find empty cell and add
data
Dim Today
Today = Now ' Assign current system date and time.
Dim MyCellCell As Range
With Worksheets("ICON Data Log")
If IsEmpty(.Cells(3, 1)) Then
Set MyCellCell = .Cells(3, 1)
ElseIf IsEmpty(.Cells(3 + 1, 1)) Then
Set MyCellCell = .Cells(3 + 1, 1)
Else
Set MyCellCell = .Cells(3, 1).End(xlDown).Offset(1, 0)
End If
MyCellValue = Today
End With
'System Data
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = " Water"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Locked = True
Selection.FormulaHidden = False
Selection.FormulaHidden = False
'Chromium
'With Workheets("ICON Data Log")
ActiveCell.Offset(0, 1).Activate
ActiveCell.Formula = "=IF(OR('Reactor Water'!F12=""Cr"",'Reactor
Water'!F13=""Cr""),LOOKUP(""B"",'Reactor Water'!F12:F13:'Reactor
Water'!G12:G13),0)"
'End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
'.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Locked = True
Selection.FormulaHidden = False'
End Sub
Ligaya