Macro to format cells from one worksheet to another

Rick93636

New Member
Joined
Jan 11, 2014
Messages
24
I have written a VBA that will format a cell in one worksheet based on the value of a cell in another worksheet. It works fine. My question is this: I have 312 cells to format. Each cell on the main worksheet looks to a different cell on the other worksheet. Is there an easier way than to write the multiple lines for each cell?

Here's the VBA:

Sub CopyTransposeAS()
'
' CopyTransposeAS Macro
' Copy and Transpose Anscillary Service
'
' Keyboard Shortcut: Ctrl+Shift+A
'
ActiveSheet.Name = "myDataTable"
Sheets("myDataTable").Select
Sheets("myDataTable").Copy After:=Workbooks("FOC daily schedule.xlsm").Sheets _
(2)
ActiveWorkbook.Save
Sheets("myDataTable").Select
Range("H7").Select
Select Case Range("h7")
Case 1 To 100
Sheets("Schedule").Select
Range("H12").Select

With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Select

End Sub

In this one the H12 cell of the Schedule worksheet looks to the H7 cell of the myDataTable worksheet. If the H7 cell has a value of 1-100 then the H12 cell will have yellow fill.

So...do I have to copy this and change the cell reference 311 more times?

Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,216,100
Messages
6,128,824
Members
449,470
Latest member
Subhash Chand

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