VBA Help

C

C

I am not a programmer but need to automate clean up of data that I have to
work with daily. I was hoping someone could please help me out.

I need to do the following:

For entire worksheet. Could be data in A1:J500 or data could be in rows
A1:AV6000.


If Column A = Then Do This:

1 Do Nothing
2 Indent Column B 5 Spaces
3 Indent Column B 10 Spaces
4 Indent Column B 15 Spaces
5 Indent Column B 20 Spaces
6 Indent Column B 25 Spaces
7 Indent Column B 30 Spaces
8 Indent Column B 35 Spaces



Also for entire worksheet. Could be data in A1:J500 or data could be in
rows A1:AV6000.

If Column B = Yes Then Bold and shade in gray this row from column A to end
of data on row. Could be column J or Column AV.

Many thanks and much appreciation in advance for your assistance.
 
G

Greg Snidow

C, you could try something like this.

Sub Cases()

Dim LastRow As Integer
Dim LastCol As Integer
Dim TargetRange As Range

'Get the last row of the range
LastRow = Cells(Rows.Count, 1).End(xlUp).Row

'Step through all cells in the range
For i = 1 To LastRow Step 1

'Get the last column in the row
LastCol = Cells(i, Columns.Count).End(xlToLeft).Column

'Set the range
Set TargetRange = Range(Cells(i, 1).Address & ":" & Cells(i,
LastCol).Address)
With TargetRange
Select Case True
Case Range("B" & i).Value = "Yes"
.Interior.ColorIndex = 15
.Font.Bold = True
End Select
End With
Next i
End Sub

Greg
 
J

JLGWhiz

Most beginners start by recoding their keystrokes using the Macro Recorder
feature. Click Tools>Macro>Record New Macro, Fill in macro name in pop up
box or just click OK. You can now begin manually executing the steps you
want to record. There should be a tool bar showing on the screen with a
button to click when you want to stop recording.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top