View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default If Then VBA statement

Is the true false in row 1?

Sub copyColumns()
Dim i As Long
For i = 3 To 7
If Cells(1, i + 10) = True Then
Cells(6, i + 10).Resize(19, 1).Copy Cells(6, i)
End If
Next
End Sub

if your true false values are in row 6

Sub copyColumns()
Dim i As Long
For i = 3 To 7
If Cells(6, i + 10) = True Then
Cells(6, i + 10).Resize(19, 1).Copy Cells(6, i)
End If
Next
End Sub

if your true false values are in row 6 and you want to copy rows 7:24

Sub copyColumns()
Dim i As Long
For i = 3 To 7
If Cells(6, i + 10) = True Then
Cells(7, i + 10).Resize(18, 1).Copy Cells(7, i)
End If
Next
End Sub

--
Regards,
Tom Ogilvy

" wrote:

I have a data set, 5 columns by 18 rows, M6:Q24. At the top of each row is a
True-False statement. I want to create a function that looks at each column,
and if the true-false statment says true will paste special the values into
columns C:G, respectively, in the same rows. If the statment says false, the
function will do nothing. Any ideas?

Thanks

Adam Bush