Formatting a workbook that is fed from another

SEvans

New Member
Joined
Nov 30, 2006
Messages
11
I'm using workbooks that are updated daily via a macro in a master workbook (it reads the current info, deletes that which are out of date and adds anything new. One of the workbooks isn't formated properly - I've tried adding a macro to do this but becuase it freshers from the master workbook, the macro disppears each time it's refreshed. This is the bit of code from that master workbook that I think relates to the workbook that I want to format I just want to change column Q to a width of 80 and wrap the text within column Q - can anyone tell how to add this in to the code below?

Code:
Set wbTemp = Workbooks.Open(wbProcessWorkbook.Path + "\Medicine15PlusDayStayers.xls")
    Set wsTemp = wbTemp.Worksheets("15 Plus Day Stayers")
    nRow = 2
    While wsTemp.Cells(nRow, 1) <> ""
        nRow = nRow + 1
    Wend
    nRow = nRow - 1
    If nRow >= 2 Then
        Set rngCells = wsTemp.Range(wsTemp.Cells(2, 1), wsTemp.Cells(nRow, 17))
        rngCells.Copy (wsOld.Cells(nNextRow, 1))
        nNextRow = nNextRow + nRow - 1
    End If
    wbTemp.Close
 
Last edited by a moderator:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Sabrina,
Try this:
<font face=Courier New><SPAN style="color:#00007F">Set</SPAN> wbTemp = Workbooks.Open(wbProcessWorkbook.Path + "\Medicine15PlusDayStayers.xls")<br><SPAN style="color:#00007F">Set</SPAN> wsTemp = wbTemp.Worksheets("15 Plus Day Stayers")<br>wsTemp.Columns("Q:Q").WrapText = <SPAN style="color:#00007F">True</SPAN><br>wsTemp.Columns("Q:Q").ColumnWidth = 80<br>nRow = 2<br><SPAN style="color:#00007F">While</SPAN> wsTemp.Cells(nRow, 1) <> ""<br>nRow = nRow + 1<br><SPAN style="color:#00007F">Wend</SPAN><br>nRow = nRow - 1<br><SPAN style="color:#00007F">If</SPAN> nRow >= 2 <SPAN style="color:#00007F">Then</SPAN><br><SPAN style="color:#00007F">Set</SPAN> rngCells = wsTemp.Range(wsTemp.Cells(2, 1), wsTemp.Cells(nRow, 17))<br>rngCells.Copy (wsOld.Cells(nNextRow, 1))<br>nNextRow = nNextRow + nRow - 1<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>wbTemp.Close


Gary
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top