This code stops part way through the column even though data exist further down with no blank cells in between.
Dim LastcRow, LastqRow, lastdtyperow, lastdqtyrow, lastqtyperow
Dim Dst
Dim Foot
Dim c
Dim cRange As Range
'defines sheets for ease of use and less confusion
Dim dataentry As Worksheet, quote1 As Worksheet
Dim typ As Range
Set dataentry = Sheets("Data Entry")
Set quote1 = Sheets("Quote")
LastcRow = Sheets("Data Entry").Range("B1").End(xlDown).Row
LastqRow = Sheets("Quote").Range("C1").End(xlDown).Row
lastdtyperow = dataentry.Range("B1").End(xlDown).Row
lastdqtyrow = dataentry.Range("C1").End(xlDown).Row
lastqtyperow = quote1.Range("A1").End(xlDown).Row
Set typ = dataentry.Range("B9:B" & lastdtyperow)
'this needs some work
Foot = Sheets("DATA VALIDATION").Range("I2").Value
'this is where the code for copying data begins
Dim i As Integer
Dim cell As Range
For i = 0 To lastdtyperow
'copies types
Set cell = dataentry.Range("B9").Offset(i, 0)
If Not IsEmpty(cell) Then
quote1.Range("A13").Offset(i, 0) = cell.Value
quote1.Range("A13").Offset(i, 0).HorizontalAlignment = xlCenter
quote1.Range("A13").Offset(i, 0).VerticalAlignment = xlCenter
End If
'copies quantities
Set cell = dataentry.Range("C9").Offset(i, 0)
If Not IsEmpty(cell) Then
quote1.Range("B13").Offset(i, 0) = cell.Value
quote1.Range("B13").Offset(i, 0).HorizontalAlignment = xlCenter
quote1.Range("B13").Offset(i, 0).VerticalAlignment = xlCenter
quote1.Range("B13").Offset(i, 0).NumberFormat = "#,##0"
End If
'copies mfr
Set cell = dataentry.Range("AB9").Offset(i, 0)
If Not IsEmpty(cell) Then
quote1.Range("C13").Offset(i, 0) = cell.Value
quote1.Range("C13").Offset(i, 0).HorizontalAlignment = xlCenter
quote1.Range("C13").Offset(i, 0).NumberFormat = "#,##0"
quote1.Range("C13").Offset(i, 0).WrapText = True
quote1.Range("C13").Offset(i, 0).VerticalAlignment = xlCenter
End If
'copies cat number
Set cell = dataentry.Range("AC9").Offset(i, 0)
If Not IsEmpty(cell) Then
quote1.Range("D13").Offset(i, 0) = cell.Value
quote1.Range("D13").Offset(i, 0).HorizontalAlignment = xlCenter
quote1.Range("D13").Offset(i, 0).WrapText = True
quote1.Range("D13").Offset(i, 0).VerticalAlignment = xlCenter
End If
'copies notes
Set cell = dataentry.Range("AD9").Offset(i, 0)
If Not IsEmpty(cell) Then
quote1.Range("E13").Offset(i, 0) = cell.Value
quote1.Range("E13").Offset(i, 0).HorizontalAlignment = xlCenter
End If
'copies prices
Set cell = dataentry.Range("AJ9").Offset(i, 0)
If Not IsEmpty(cell) Then
quote1.Range("F13").Offset(i, 0) = cell.Value
quote1.Range("F13").Offset(i, 0).HorizontalAlignment = xlRight
quote1.Range("F13").Offset(i, 0).VerticalAlignment = xlCenter
quote1.Range("F13").Offset(i, 0).NumberFormat = "$#,##0.00"
quote1.Range("F13").Offset(i, 0).Font.Bold = False
End If
Next i
The For i = 0
is my copying loop that is not working as intended.
This code is my "control" for subsequent code. It determines if i
needs to increase and the process be repeated. Once it hits the last cell with data in column B on dataentry, the code is supposed to stop and move to the next portion of sheet generation.
I tried changing the range of lastdtyperow
, change xlDown
to xlUp
and other various odds and ends. If anything, changing ranges and xldown
/xlup
made the issue worse where it would stop even sooner and some changes caused Excel to lock up/crash.