![]() |
VBA Code
Hello,
I have recently started using VB for my excel sheet by recording a macro and manipulating the code. However, I'm stuck with a problem which I am hoping someone will be able to help me with. In my macro, I insert a column and then a formula on the first line. Then I double click on the right hand side of my cell which copies the formula to the bottom of all my records. However, when i look at the coding it put the copying as an absolute value ie. F2:F2555. As my data is being pulled through a ODBC link and is dependant on the date field (the user can enter a date range for the report) the number of records it will bring up will be different every time. Is there anyway, I can change the code so it copies the formula to all records no matter how many there are. I do not want the formula to be copied into cells with empty records as I will be using the info to create a pivot table afterwards. Any help will be much appreciated. Thanks B |
VBA Code
BMistry,
You can find the Last Row of data in columnE with LastRow = Range("E" & Rows.Count).End(xlUp).row and use it for autofill Range("F2").AutoFill _ Destination:=Range("F2:F" & LastRow) HTH Cecil "BMistry" wrote in message ... Hello, I have recently started using VB for my excel sheet by recording a macro and manipulating the code. However, I'm stuck with a problem which I am hoping someone will be able to help me with. In my macro, I insert a column and then a formula on the first line. Then I double click on the right hand side of my cell which copies the formula to the bottom of all my records. However, when i look at the coding it put the copying as an absolute value ie. F2:F2555. As my data is being pulled through a ODBC link and is dependant on the date field (the user can enter a date range for the report) the number of records it will bring up will be different every time. Is there anyway, I can change the code so it copies the formula to all records no matter how many there are. I do not want the formula to be copied into cells with empty records as I will be using the info to create a pivot table afterwards. Any help will be much appreciated. Thanks B |
All times are GMT +1. The time now is 05:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com