Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 7
Default Help linking true false in column to start macros

Hi,
I have been trying to get a macros to run based on the value of a cell in Column D.
What I would like it to do. Look down through column "D" when the value of the cell is true perform a macros (which i have created). It has to recognize that the cell with the value of true is the "Activecell" as my macros is setup for active cell.
My code looks like this so far
Sub MacrosTest()
'
'
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveCell.Range("A1:C1").Select
Selection.Copy
Sheets("Blank Stickers").Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.Select
ActiveSheet.Paste
Sheets("File").Select
ActiveCell.Select

End Sub

The Names of the sheets a
File
Blank Stickers
  #2   Report Post  
Member
 
Location: Bangalore
Posts: 41
Thumbs up

Quote:
Originally Posted by jt24152 View Post
Hi,
I have been trying to get a macros to run based on the value of a cell in Column D.
What I would like it to do. Look down through column "D" when the value of the cell is true perform a macros (which i have created). It has to recognize that the cell with the value of true is the "Activecell" as my macros is setup for active cell.
My code looks like this so far
Sub MacrosTest()
'
'
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveCell.Range("A1:C1").Select
Selection.Copy
Sheets("Blank Stickers").Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.Select
ActiveSheet.Paste
Sheets("File").Select
ActiveCell.Select

End Sub

The Names of the sheets a
File
Blank Stickers
Hi,

Try this.

Sub CheckForsomething()
Range("D1").Activate
Do While ActiveCell.Value < ""
If ActiveCell.Value = True Then Call Macrotest
ActiveCell.Offset(1, 0).Activate
Loop
End Sub

This code will start from Range D1 and will keep looking in column D until there is either an empty cell or the value of the cell is True.

If the value of cell is true this will call your procedure (macrotest).

Instead of calling the macro you may like to substitute your code in my procedure. Either ways, your purpose should be complete.

Let me know if it helps.

Thanks,
Prashant
  #3   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by jack_n_bub View Post
Hi,

Try this.

Sub CheckForsomething()
Range("D1").Activate
Do While ActiveCell.Value < ""
If ActiveCell.Value = True Then Call Macrotest
ActiveCell.Offset(1, 0).Activate
Loop
End Sub

This code will start from Range D1 and will keep looking in column D until there is either an empty cell or the value of the cell is True.

If the value of cell is true this will call your procedure (macrotest).

Instead of calling the macro you may like to substitute your code in my procedure. Either ways, your purpose should be complete.

Let me know if it helps.

Thanks,
Prashant
Well. It is doing something but not what i would have hoped.
Currently it runs clear down my list of numbers but it is still only performing the macros of copy pasting from the current sheet (File) to the other sheet (Blank Stickers) in the row of the active cell at which i have selected prior to runs the macros. It doesn't seem to be looking for true/false/blank in column "D". Frustrating.
Any other ideas?
  #4   Report Post  
Member
 
Location: Bangalore
Posts: 41
Default

Quote:
Originally Posted by jt24152 View Post
Well. It is doing something but not what i would have hoped.
Currently it runs clear down my list of numbers but it is still only performing the macros of copy pasting from the current sheet (File) to the other sheet (Blank Stickers) in the row of the active cell at which i have selected prior to runs the macros. It doesn't seem to be looking for true/false/blank in column "D". Frustrating.
Any other ideas?
Hi,

Is it fine for you to share a sample. As told earlier, there are better ways to perform your task but I provided the solution as per your requirement.

I can look into your code and make necessary corrections and send it back to you.

By the way, you need to run my macro after you have activated the sheet which has column D you are checking for. And I am also assuming that the keyword True is a logical value not a text, i.e. not "TRUE" but TRUE (logical value).

Thanks,
Prashant
  #5   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by jack_n_bub View Post
Hi,

Is it fine for you to share a sample. As told earlier, there are better ways to perform your task but I provided the solution as per your requirement.

I can look into your code and make necessary corrections and send it back to you.

By the way, you need to run my macro after you have activated the sheet which has column D you are checking for. And I am also assuming that the keyword True is a logical value not a text, i.e. not "TRUE" but TRUE (logical value).

Thanks,
Prashant
Ok. I am trying to attach it but having difficulties.
I found this online an it works to find the first true in column D but wont loop.


  #6   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by jt24152 View Post
Ok. I am trying to attach it but having difficulties.
I found this online an it works to find the first true in column D but wont loop.
Sub Test3()
Dim x As String
Dim found As Boolean
' Select first line of data.
Range("D1").Select
' Set search variable value.
x = True
' Set Boolean variable "found" to false.
found = False
' Set Do loop to stop at empty cell.
Do Until IsEmpty(ActiveCell)
' Check active cell for search value.
If ActiveCell.Value = x Then
found = True
Exit Do
End If
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
' Check for found.
If found = True Then
MsgBox "Value found in cell " & ActiveCell.Address
Else
MsgBox "Value not found"
End If
End Sub
  #7   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by jt24152 View Post
Sub Test3()
Dim x As String
Dim found As Boolean
' Select first line of data.
Range("D1").Select
' Set search variable value.
x = True
' Set Boolean variable "found" to false.
found = False
' Set Do loop to stop at empty cell.
Do Until IsEmpty(ActiveCell)
' Check active cell for search value.
If ActiveCell.Value = x Then
found = True
Exit Do
End If
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
' Check for found.
If found = True Then
MsgBox "Value found in cell " & ActiveCell.Address
Else
MsgBox "Value not found"
End If
End Sub
Ok I have attached a sample of what I hav been trying to do. Hope this helps
Attached Files
File Type: zip Copy of Work2.zip (69.2 KB, 30 views)
  #8   Report Post  
Junior Member
 
Posts: 7
Default

So your formula works great now that I moved the True/False to column "A"

The only other think is my Macros I created to copy and paste from Sheet1 to sheet2 stops with an error and will not continue to loop the checkforsomething.

Any ideas on how to fix it so after my macros is finished that it continues on with the one you gave me?
Here is my code
Sub Move()
'
' Move Macro
'

'
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(0, 1).Range("A1:C1").Select
Selection.Copy
Sheets("BlankStickers").Select
ActiveCell.Offset(-2, 0).Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("File").Select
End Sub


It stops on Sheets("File").Select
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
Assign different macros for True/False button Ken G. Excel Discussion (Misc queries) 2 April 3rd 09 04:50 AM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Discussion (Misc queries) 9 July 29th 08 12:28 AM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Programming 9 July 29th 08 12:28 AM
Linking check boxes so if one is true the other shows false Carl Excel Discussion (Misc queries) 4 September 8th 06 03:18 AM
True / false statements in Macros RogerNZ Excel Programming 3 June 14th 04 03:13 AM


All times are GMT +1. The time now is 03:51 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"