Assigning & Formatting via V/B. (Excel 2003)

elliott740

Board Regular
Joined
Mar 14, 2008
Messages
52
I am using the following code and it works just fine but is there a better way to do it? Can I do the assignment and the formatting in one step?

[For MthCtr = QtrStart To BwCol Step 4
Worksheets(WorksheetName).Cells(RowCounter, 12).Value = Worksheets(WorksheetName).Cells(RowCounter, 12).Value + Worksheets("Sales_Query1").Cells(LoopCounter, MthCtr).Value 'QTD Sales
Worksheets(WorksheetName).Cells(RowCounter, 13).Value = Worksheets(WorksheetName).Cells(RowCounter, 13).Value + Worksheets("Sales_Query1").Cells(LoopCounter, MthCtr + 1).Value 'QTD Budget
Worksheets(WorksheetName).Cells(RowCounter, 14).Value = Worksheets(WorksheetName).Cells(RowCounter, 14).Value + Worksheets("Sales_Query1").Cells(LoopCounter, MthCtr - 48).Value 'QTD LY Sales
Next MthCtr
With Worksheets(WorksheetName)
.Range("L7:N14").NumberFormat = "$#,##0_);($#,##0)"
End With
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
As far as I can see you are copying between non-contiguous ranges.

So I don't think you can do the copying and formatting at the same time, not without a fair bit more code.

Do you really need/want to do that anyway?

The formatting is being applied in one go at the end.
 
Upvote 0

elliott740

Board Regular
Joined
Mar 14, 2008
Messages
52
If I did it on a one for one basis (as I am doing the assigning cell by cell) could it be done using one statement or would I have to assign it in one line and then format it in the next line?
 
Upvote 0

Forum statistics

Threads
1,190,913
Messages
5,983,531
Members
439,848
Latest member
timmyo

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
Top