Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
Quote:
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
|
|||
|
|||
Quote:
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
|
|||
|
|||
Quote:
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
|
|||
|
|||
Quote:
I found this online an it works to find the first true in column D but wont loop. |
#6
|
|||
|
|||
Quote:
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
|
|||
|
|||
Quote:
|
#8
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Assign different macros for True/False button | Excel Discussion (Misc queries) | |||
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 | Excel Discussion (Misc queries) | |||
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 | Excel Programming | |||
Linking check boxes so if one is true the other shows false | Excel Discussion (Misc queries) | |||
True / false statements in Macros | Excel Programming |