Martin2k Forums

Board index Visual Basic Visual Basic Help

VBA & Excel: macro wont save column adjustments

Ask for help on versions of Visual Basic 6.0 or earlier.

VBA & Excel: macro wont save column adjustments

Postby jacjacjac » Fri Apr 20, 2012 7:23 am

Hello,

My Aim: i wish to place text in one sheet and adjust columns in another sheet using similar code or the code below

Problem: It runs the Sub however, it executes the code to place the text 'XXX' in the correct spot, however it wont adjust the columns. Once i open the file up the text is there but columns haven't changed.
I figured the code is similar so why is it executing and saving the text but not the column widths.

I think it might be that the column manipulation needs to be saved? If so, howr? If not any ideas?

(also this Sub is called from a macro that runs over an Excel file, that (the macro) is called from a form in Access)

Sample code
Code: Select all
[Private Sub editCols()

Dim frontSht As Worksheet
Set frontSht = Sheets("Front_sheet")

frontSht.Range("H2").Value = "XXX"

Dim backSht As Worksheet

Set backSht = Sheets("Full_Revision_History")

backSht.Columns("A:Q").AutoFit
backSht.Range("A:P").HorizontalAlignment = xlCenter

End Sub

Thanks,
jacjacjac
Newcomer
 
Posts: 4
Joined: Fri Dec 30, 2011 3:00 am

Return to Visual Basic Help

Who is online

Users browsing this forum: No registered users and 1 guest