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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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)
 
Upvote 0
Are Sheet1 and wsSheet the same sheet?
 
Upvote 0
Yes, I'm guessing you have worked out that I am no good at VB?
 
Upvote 0
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)
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,309
Members
448,564
Latest member
ED38

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