stirlingmw1
Board Regular
- Joined
- Jun 17, 2016
- Messages
- 53
- Office Version
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Morning All
I have a workbook where I am keeping track of ammunition allowances for my ships. Data is added to worksheets based on criteria set in a CmboBox. I can get the most of the data added to the correct worksheets using set columns and a Lastrow range, but there is one worksheet that data needs to be added to the next empty column rather than set columns. For the life of me I cannot seem to get my code to work.
I need the Data to be added to the WSName1 worksheet, where the first 2 columns have fixed data and the third will be where the new data starts to be added moving right. The Lastrow is defined by the qty of rows used in the "Requirements" worksheet (currently 28).
I have trawled the internet and tried multiple variations of the final row of code but nothing seems to work. The only thing that did work is when I used:
but this only added data to the first Cell of the available column. Where am I going wrong
Thanks
Steve
I have a workbook where I am keeping track of ammunition allowances for my ships. Data is added to worksheets based on criteria set in a CmboBox. I can get the most of the data added to the correct worksheets using set columns and a Lastrow range, but there is one worksheet that data needs to be added to the next empty column rather than set columns. For the life of me I cannot seem to get my code to work.
I need the Data to be added to the WSName1 worksheet, where the first 2 columns have fixed data and the third will be where the new data starts to be added moving right. The Lastrow is defined by the qty of rows used in the "Requirements" worksheet (currently 28).
VBA Code:
Lastrow = Worksheets("Requirements").Cells(Rows.Count, 2).End(xlUp).Row
LastColumn = Worksheets(WSName1).Cells(3, Columns.Count).End(xlToLeft).Column + 1
Worksheets(WSName1).Range(3, LastColumn & LastColumn & Lastrow).Value = Worksheets("Requirements").Range("I3:I" & Lastrow).Value
I have trawled the internet and tried multiple variations of the final row of code but nothing seems to work. The only thing that did work is when I used:
VBA Code:
Worksheets(WSName1).Cells(3, LastColumn).Value = Worksheets("Requirements").Range("I3:I" & Lastrow).Value
but this only added data to the first Cell of the available column. Where am I going wrong
Thanks
Steve