Put data on next blank row

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,035
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)
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,035
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
13,828
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,035
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
13,828
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)
 

Watch MrExcel Video

Forum statistics

Threads
1,122,509
Messages
5,596,558
Members
414,077
Latest member
ammylar5

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