Hello awesome VBA gurus,
I'm working on a VBA script for processing some data from a couple of workbooks and creating a pivot chart. I am mostly done but have an issue that I'm hoping someone here can help me with.
Columns A & B will contain start/end dates and times which get pulled from a database query. The number of date/time values in these columns will vary with each query.
I want to find out if there is a way to change the range selections that I have below from fixed to dynamic. In the example code below Column C has cells with data down to C308 and I'm manually selecting the range to auto fill the data in the range A301:B308 based on what I have in A301:B301. Is there a way that I can use the last cell in colum C as a reference to determine my lastrow and then fill column A and B up until the first empty cell in A & B?
I have used the following function to autofill cells in another column but not sure how to implement this in the case above.
Thank you.
I'm working on a VBA script for processing some data from a couple of workbooks and creating a pivot chart. I am mostly done but have an issue that I'm hoping someone here can help me with.
Columns A & B will contain start/end dates and times which get pulled from a database query. The number of date/time values in these columns will vary with each query.
I want to find out if there is a way to change the range selections that I have below from fixed to dynamic. In the example code below Column C has cells with data down to C308 and I'm manually selecting the range to auto fill the data in the range A301:B308 based on what I have in A301:B301. Is there a way that I can use the last cell in colum C as a reference to determine my lastrow and then fill column A and B up until the first empty cell in A & B?
Code:
' Copy down DT_TM values and format
Range("A2000").End(xlUp).Offset(1, 0).Select
Range("A301:B301").Select
Selection.AutoFill Destination:=Range("A301:B308"), Type:=xlFillDefault
Range("A301:B308").Select
Range("A1:B1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.NumberFormat = "m/d/yy h:mm;@"
I have used the following function to autofill cells in another column but not sure how to implement this in the case above.
Code:
lastrow = Range("I2000").Endxlup.Row
Selection.AutoFill Destination:=Range("J2:J" & lastrow), Type:=xlFillDefault
Thank you.