osevero
11-10-2013, 10:21 PM
Hi!
I have this code that writes data from one worksheet to another.
Sub Save()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lngRC As Long
Dim var
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
With ws2
lngFF = .Range("B" & Rows.Count).End(xlUp).Row + 1
End With
var = Array(6, 11, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 53, 56, 57, 58)
For lngRC = LBound(var) To UBound(var)
ws2.Cells(lngFF, lngRC + 2).Value = ws1.Cells(var(lngRC), "C").Value
Next lngRC
ws1.Range("C7:C8").ClearContents
ws1.Range("C10").ClearContents
ws1.Range("C12:C15").ClearContents
ws1.Range("C17:C19").ClearContents
ws1.Range("C28:F47").ClearContents
Set ws2 = Nothing
Set ws1 = Nothing
End Sub
But I want to limit this code only works if cell C53 has some data. If cell C53 doesn't have any number, then a message: "You must fill in more data". If the cell C53 has number, then the code proceeds.
I have this code that writes data from one worksheet to another.
Sub Save()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lngRC As Long
Dim var
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
With ws2
lngFF = .Range("B" & Rows.Count).End(xlUp).Row + 1
End With
var = Array(6, 11, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 53, 56, 57, 58)
For lngRC = LBound(var) To UBound(var)
ws2.Cells(lngFF, lngRC + 2).Value = ws1.Cells(var(lngRC), "C").Value
Next lngRC
ws1.Range("C7:C8").ClearContents
ws1.Range("C10").ClearContents
ws1.Range("C12:C15").ClearContents
ws1.Range("C17:C19").ClearContents
ws1.Range("C28:F47").ClearContents
Set ws2 = Nothing
Set ws1 = Nothing
End Sub
But I want to limit this code only works if cell C53 has some data. If cell C53 doesn't have any number, then a message: "You must fill in more data". If the cell C53 has number, then the code proceeds.