Cannot jump to cells because it is hidden.

daw60

New Member
Joined
Jan 26, 2015
Messages
14
Office Version
  1. 2016
Platform
  1. Windows
Sub Adddata ()
Dim lr As Variant
Sheets("RUNNING TOTAL").Select
lr = Cells.find ("*", Cells(3, 9), xlforumlas, xlPart, xlByRows, xlPrevious, False).Row
Range("I3:K&lr").Copy

Sheets("annual").Select
lrANNUAL = Cells.find ("*", Cells(1, 1), xlforumlas, xlPart, xlByRows, xlPrevious, False).Row
Cells(lrANNUAL + 1, 1).Select
ActiveSheet.Paste

End Sub

The error occurs above in red.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi daw60,

it's xlFormulas, Range("I3:K" & lr).Copy...

Try

VBA Code:
Sub AddData()
Dim lr As Long
Dim lrANNUAl As Long
With Sheets("RUNNING TOTAL")
  lr = .Cells.Find("*", .Cells(3, 9), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
End With

With Sheets("annual")
  lrANNUAl = .Cells.Find("*", .Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
  Sheets("RUNNING TOTAL").Range("I3:K" & lr).Copy .Cells(lrANNUAl + 1, 1)
End With
End Sub

Ciao,
Holger
 
Upvote 0
Hi daw60,

it's xlFormulas, Range("I3:K" & lr).Copy...

Try

VBA Code:
Sub AddData()
Dim lr As Long
Dim lrANNUAl As Long
With Sheets("RUNNING TOTAL")
  lr = .Cells.Find("*", .Cells(3, 9), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
End With

With Sheets("annual")
  lrANNUAl = .Cells.Find("*", .Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
  Sheets("RUNNING TOTAL").Range("I3:K" & lr).Copy .Cells(lrANNUAl + 1, 1)
End With
End Sub

Ciao,
Holger
 
Upvote 0
it works almost... there are several rows of data that should have been copied but only the first line was actually copied and pasted.
 
Upvote 0
Hi daw60,

and what value does lr hold?

Maybe try using either

VBA Code:
Sub AddData_mod2()
Dim lr As Long
Dim lrANNUAl As Long
With Sheets("RUNNING TOTAL")
  lr = .Cells(.Rows.Count, "K").End(xlUp).Row
End With

With Sheets("annual")
  lrANNUAl = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
  .Cells(lrANNUAl, 1).Resize(lr - 2, 3).Value = Sheets("RUNNING TOTAL").Range("I3:K" & lr).Value
End With

End Sub

or

VBA Code:
Sub AddData_mod3()
Dim lr As Long
Dim lrANNUAl As Long
With Sheets("RUNNING TOTAL")
  lr = .Cells.SpecialCells(xlCellTypeLastCell).Row
End With

With Sheets("annual")
  lrANNUAl = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
  .Cells(lrANNUAl, 1).Resize(lr - 2, 3).Value = Sheets("RUNNING TOTAL").Range("I3:K" & lr).Value
End With

End Sub

Both codes will copy just the values to Sheet "annual".

Ciao,
Holger
 
Upvote 0
Solution
Hi daw60,

and what value does lr hold?

Maybe try using either

VBA Code:
Sub AddData_mod2()
Dim lr As Long
Dim lrANNUAl As Long
With Sheets("RUNNING TOTAL")
  lr = .Cells(.Rows.Count, "K").End(xlUp).Row
End With

With Sheets("annual")
  lrANNUAl = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
  .Cells(lrANNUAl, 1).Resize(lr - 2, 3).Value = Sheets("RUNNING TOTAL").Range("I3:K" & lr).Value
End With

End Sub

or

VBA Code:
Sub AddData_mod3()
Dim lr As Long
Dim lrANNUAl As Long
With Sheets("RUNNING TOTAL")
  lr = .Cells.SpecialCells(xlCellTypeLastCell).Row
End With

With Sheets("annual")
  lrANNUAl = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
  .Cells(lrANNUAl, 1).Resize(lr - 2, 3).Value = Sheets("RUNNING TOTAL").Range("I3:K" & lr).Value
End With

End Sub

Both codes will copy just the values to Sheet "annual".

Ciao,
Holger
The second suggestion works perfectly.
Thank you for your help!
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top