Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default If Then VBA statement

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default If Then VBA statement

If you wanted to use formulas, you could use this in C6 and just copy it
over and down.
=IF(M6="","",IF(M$5=TRUE,M6,""))

Through VBA, here's one way assuming your True/False values are in row 5:

For Each cell In Range("M5:Q5")
If cell.Value = True Then Range(cell.Offset(1, -10),
cell.Offset(19, -10)).Value = _
Range(cell.Offset(1, 0), cell.Offset(19, 0)).Value
Next cell

HTH,
Paul

"
m wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 461
Default If Then VBA statement

Sub test()
Range("N5").Activate

For x = 1 to 5

ActiveCell.Offset(0,x)
If ActiveCell.Value = "True" Then
Range(ActiveCell.Offset(1,0),ActiveCell.Offset(1,0 ).End(xlDown)).Copy
Range("B5").Offset(0,x).PasteSpecial (xlPasteValues)
End If

Next x

End Sub


" 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default If Then VBA statement

Thanks a lot for your help guys

"PCLIVE" wrote:

If you wanted to use formulas, you could use this in C6 and just copy it
over and down.
=IF(M6="","",IF(M$5=TRUE,M6,""))

Through VBA, here's one way assuming your True/False values are in row 5:

For Each cell In Range("M5:Q5")
If cell.Value = True Then Range(cell.Offset(1, -10),
cell.Offset(19, -10)).Value = _
Range(cell.Offset(1, 0), cell.Offset(19, 0)).Value
Next cell

HTH,
Paul

"
m wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM
If statement and Isblank statement Rodney C. Excel Worksheet Functions 0 January 18th 05 08:39 PM


All times are GMT +1. The time now is 07:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"