igorski88
07-06-2013, 11:02 AM
Im sending data to to a different Workbook. the workBook will be a basic electronic LogBook of transactions. I have it working with one minor issue. The first column is shifted down one row. "A1" is giving me all my problems. Please help me with this minor problem. I have been going at this for hours!! someone... BE MY HERO!!!
Sub Transfer_Data()Dim ThisWB As Variant
Dim LogBookName As Variant
Dim Lastrow As Long
ThisWB = ThisWorkbook.Name
Set LogBook = Workbooks.Open(fn)
LogBookName = LogBook.Name
With Workbooks(LogBookName).Sheets("sheet1")
'Find the last row used
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
MsgBox Lastrow
'IGOR: heading and data will be on the same row.... need to seperat the rows
'Populat Heading
If checkHeading = True Then
'Date Recorded 'Heading
If check1 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = "Date Recorded:"
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = "Date Recorded:"
End If
End If 'Date Recorded
'Type of Transaction 'Heading
If check2 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = "Type of Transaction:"
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = "Type of Transaction:"
End If
End If 'Type of Transaction
'Date of Transaction 'Heading
If check3 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = "Date of Transaction:"
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = "Date of Transaction:"
End If
End If 'Date of Transaction
End If '''''''''Heading
'Find the last row used again
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
MsgBox Lastrow
'Date Recorded
If check1 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = Date
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = Date
End If
End If 'Date Recorded
'Type of Transaction
If check2 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = Sheet2.Range("AB7").Value & "/" & Sheet2.Range("B6").Value
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = Sheet2.Range("AB7").Value & "/" & Sheet2.Range("B6").Value
End If
End If 'Type of Transaction
'Date of Transaction
If check3 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = Sheet2.TextBox13.Text
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = Sheet2.TextBox13.Text
End If
End If 'Date of Transaction
'AUTO fIT Colomns
.Range("A1:Z2").Columns.Select 'autofit requires columns to be selected
.Range("A1:Z2").Columns.AutoFit
End With
'Lastly save and close Logbook
LogBook.Save
LogBook.Close
End Sub
Sub Transfer_Data()Dim ThisWB As Variant
Dim LogBookName As Variant
Dim Lastrow As Long
ThisWB = ThisWorkbook.Name
Set LogBook = Workbooks.Open(fn)
LogBookName = LogBook.Name
With Workbooks(LogBookName).Sheets("sheet1")
'Find the last row used
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
MsgBox Lastrow
'IGOR: heading and data will be on the same row.... need to seperat the rows
'Populat Heading
If checkHeading = True Then
'Date Recorded 'Heading
If check1 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = "Date Recorded:"
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = "Date Recorded:"
End If
End If 'Date Recorded
'Type of Transaction 'Heading
If check2 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = "Type of Transaction:"
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = "Type of Transaction:"
End If
End If 'Type of Transaction
'Date of Transaction 'Heading
If check3 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = "Date of Transaction:"
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = "Date of Transaction:"
End If
End If 'Date of Transaction
End If '''''''''Heading
'Find the last row used again
Lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
MsgBox Lastrow
'Date Recorded
If check1 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = Date
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = Date
End If
End If 'Date Recorded
'Type of Transaction
If check2 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = Sheet2.Range("AB7").Value & "/" & Sheet2.Range("B6").Value
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = Sheet2.Range("AB7").Value & "/" & Sheet2.Range("B6").Value
End If
End If 'Type of Transaction
'Date of Transaction
If check3 = True Then
If .Range("a" & Lastrow).Offset(1, 0).Value = "" Then
.Range("a" & Lastrow).Offset(1, 0).Value = Sheet2.TextBox13.Text
Else
.Range("Z" & Lastrow).End(xlToLeft).Offset(0, 1).Value = Sheet2.TextBox13.Text
End If
End If 'Date of Transaction
'AUTO fIT Colomns
.Range("A1:Z2").Columns.Select 'autofit requires columns to be selected
.Range("A1:Z2").Columns.AutoFit
End With
'Lastly save and close Logbook
LogBook.Save
LogBook.Close
End Sub