struggle changing formatting & borders range by vba without any result

Ali M

Active Member
Joined
Oct 10, 2021
Messages
290
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hello
I no know what happens for me .
I arrange the sheet by cancel merged cells and delete some columns by the first macro .after that I want creating formatting by second macro but doesn't change the FontStyle and BOLD

first macro
VBA Code:
Sub LoopThroughSheets()
    Dim ws As Worksheet
    Set ws = Sheets("sh")
     ws.Range("1:1", "2:2").Delete
     ws.Columns("F").Delete
      ws.Columns("D").Delete
     ws.UsedRange.UnMerge
  
End Sub
second macro
VBA Code:
Sub n()
With Sheets("sh")
 .Cells(1).Resize(1, 4).Value = Array("item", "brand", "ref.no", "qty")
 .Cells(1).Resize(1, 4).Font.Color = vbBlack
 .Cells(1).Resize(1, 4).Font.Bold = True
 .Columns("A:D").HorizontalAlignment = xlCenter
 .Columns("A:D").Font.FontStyle = "Times New Roman"
 .Columns("A:D").Font.Size = 12
 .Columns("A:D").AutoFit
    End With
End Sub
any help experts ,please?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You need to use the font name like
VBA Code:
 .Columns("A:D").Font.Name = "Times New Roman"
 
Upvote 0
Solution
this fixes all of the problems .:)
many thanks for your help .(y)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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