VBA to find next Column in a given range

ShoYnn

Board Regular
Joined
Mar 20, 2019
Messages
60
Office Version
  1. 2016
Platform
  1. Windows
I am trying to build a work calendar where jobs can be input in specific day blocks. The calendar is oriented by row where the next day is in the next row down, and the jobs are put into the columns for those associated days. Columns O through V are set up for the jobs allocated to those days. I have some VBA set up to put the first job for that given day in column O, and I am looking for some code that will put the next job scheduled for that day in the next available column (in this case P), but not to exceed column V as I have more functions and information in columns W onwards. I have tried using

Dim lastcol As Long
Last col = Cells(wrkrow, Columns.Count).End(xlToLeft).Column

Where wrkrow is the row number for the day that the work is to be performed, and this gives me column O which has data in it as it is the first column that the job is put into, and I have tried it with xlToRight which gives me column W which already has data in it. I am so confused!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Alright, I figured it out! Instead of Columns.Count I put column V (or 22 as the function wants the column number) and it works perfectly!
 
Upvote 0
Solution

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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