Put data on next blank row

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I need to put data on to the next blank row, but my mind has gone blank

VBA Code:
Sheet1.Range("b1") = Staff_Name(0)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
Its ok I have done it

VBA Code:
Dim  wsSheet As WorkSheet
 Set wsSheet = wb.Sheets("Sheet1")
wsSheet.Cells(Sheet1.Cells(Sheet1.Rows.Count, "B").End(xlUp).Row + 1, "B").Value = Staff_Name(0)
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,468
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Are Sheet1 and wsSheet the same sheet?
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
Yes, I'm guessing you have worked out that I am no good at VB?
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,468
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
It is just that you are mixing the sheets codename with the sheets tab name and they can refer to different sheets (the sheets codename is the name that appears outside the brackets when you look in the VBE project window (the tab name is the name inside the brackets btw)).

See the image below for an example.

1595529746786.png


You should really use one or the other so in your case...

VBA Code:
Dim wsSheet As Worksheet
Set wsSheet = wb.Sheets("Sheet1")
wsSheet.Cells(wsSheet.Cells(wsSheet.Rows.Count, "B").End(xlUp).Row + 1, "B").Value = Staff_Name(0)
or
VBA Code:
Sheet1.Cells(Sheet1.Cells(Sheet1.Rows.Count, "B").End(xlUp).Row + 1, "B").Value = Staff_Name(0)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,275
Messages
5,836,336
Members
430,421
Latest member
Natas

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
Top