I have an Excel export out of Access that will always be 6 columns wide, but the number of rows will change with each export. I want to write the macro to set borders for that area, but am having a difficult time trying to figure out the code. I can have a cell do the math to tell me how many rows there are that need to have borders, but how can I add a statement that says I need a range starting at A2, that is 6 columns wide and covers rows = value of B2?
Don't use a cell to calculate the range.
Add a loop to your macro so that it goes down each cell in the first column until it hits an empty cell. Then subtract 1 from ActiveCell.Row, and use that value to calculate your range. If you use intRows as your variable, your command to set the range will be something like:
Range("A2:F" & intRows).CODE
The worksheet object has the UsedRange property that tells you how much of the worksheet is in use. ActiveSheet.UsedRange.Rows.Count would give you the number of rows used in the active worksheet, for example.
In general, the UsedRange might include rows that only look empty. That shouldn't be an issue with data straight from Access.