Hi
1. I have previously managed to copy and paste cells from one worksheet (named: Form) to another Worksheet (selected in Cell C4). I have managed to get it to copy the column into a row on the correct sheet, but I can't get it to go to the next available line.
2. I also want it to go to another tab, where all the data will be stored (in the same workbook, tab = "Data")
3. If one of the Cells (C28) = a specific word I want the data to also be copy and pasted into the tab i.e "B"
this is my current code:
Sub Copy_Data()
Dim hh As Worksheet, exist As Boolean, h As Worksheet, sh As Worksheet
Dim f As Range
Set hh = Sheets("Form")
If hh.Range("C4") = "" Then
MsgBox "Enter Hospital", vbCritical
Exit Sub
End If
If hh.Range("c5") = "" Then
MsgBox "Enter Ward", vbCritical
Exit Sub
End If
exist = False
For Each h In Sheets
If LCase(h.Name) = LCase(hh.Range("C4").Value) Then
Set sh = h
exist = True
Exit For
End If
Next
If exist = False Then
MsgBox "The sheet does not exist", vbCritical
Exit Sub
End If
Set f = sh.Range("A1").Find(hh.Range("c4").Value, , xlValues, xlWhole)
If f Is Nothing Then
MsgBox "This does not exist", vbCritical
Else
'Copy data to Site Sheet'
'cell destination cell origin
sh.Cells(Rows.Count, 1, "a:u").Value = hh.Range("C4:c23").Value
End If
End Sub
Any help is much appreciated.
Bookmarks