The following issue affects me. I appreciate your assistance in advance. -

I'm attempting to set up 7 charts [Doughnut] in a 3x4 arrangement, meaning I want the charts to be arranged in 3 columns and 4 rows. What my code prints in an Excel worksheet is shown below.

I want it printed in this fashion:

This is the code that I have:

```        Const TopAnchor As Long = 8
Const LeftAnchor As Long = 140
Const HorizontalSpacing As Long = 3
Const VerticalSpacing As Long = 3
Const ChartHeight As Long = 125
Const ChartWidth As Long = 210

Dim Counter As Long
Counter = 0 Counter = Counter + 1

With ActiveChart.Parent
.Top = TopAnchor + (WorksheetFunction.RoundUp(Counter / 3, 0) - 1) * (VerticalSpacing + ChartHeight)
.Left = LeftAnchor + ((Counter) Mod 4) * (HorizontalSpacing + ChartWidth)
.Height = 125
.Width = 200
End With```
Apr 9, 2023 in Others 415 views

## 1 answer to this question.

Your code was nearly complete. I believed numChartsPerRow needed to be an additional constant. Row and column calculations were also split out because they weren't quite right. These are completed in advance only as an example for debugging, but they might be completed along the same lines. Top = or . Left=

Fun question. And my answer was less than a minute behind Tim's.....

```Sub adjustCharts()
Const numChartsPerRow = 3
Const TopAnchor = 8
Const LeftAnchor = 140
Const HorizontalSpacing = 3
Const VerticalSpacing = 3
Const ChartHeight = 125
Const ChartWidth = 210

Dim ws As Worksheet, Counter As Long, zChartSet As ChartObject, _
colPos As Long, rowNumber As Long

Set ws = ActiveSheet '<--- your worksheet

For Each zChartSet In ws.ChartObjects
rowNumber = Int(Counter / numChartsPerRow)
colPos = Counter Mod numChartsPerRow

With zChartSet
.Top = TopAnchor + rowNumber * (VerticalSpacing + ChartHeight)
.Left = LeftAnchor + colPos * (HorizontalSpacing + ChartWidth)
.Height = ChartHeight
.Width = ChartWidth
End With

Counter = Counter + 1
Next zChartSet

End Sub
```

• 63,720 points

## ERROR: You need elevated Administrator privileges in order to run this script.

Hi@akhtar, I guess you are trying to run ...READ MORE

## Ordering by the order of values in a SQL IN() clause

We can use expressions as well in ...READ MORE

## Ordering by the order of values in a SQL IN() clause

Use MySQL FIND_IN_SET function: SELECT * ...READ MORE

## Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

## How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

## Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE