in execl minimum limit of raw and columan - excel

Respected Sir/Madam
I want to key 60 records in first sheet, and 61th records key on next sheet. I want after
60 records cursur is go to automaticully 61th records.
means after every 60th records curuser is going to next sheet.
Thankyou

From your question I think you need to use the SelectionChange event to detect when a cell on any row >60 is selected.
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Row > 60 Then
Sheets(ActiveSheet.Index + 1).Activate
ActiveSheet.Range("A1").Activate
End If
End Sub
This code would need to be placed in each worksheet code module that you wanted the automatic jump to the next worksheet to happen in. It makes the following assumptions:
It fires any time a cell with row number >60 is selected
It just increments the worksheet index to get the next sheet
It assumes your data starts in cell A1
This should allow you to get started though.

With some presto code I would say the logic would be something like this
If ActiveSheet=”Sheet1” AND ActiveRow>=61 then
ActiveSheet=”Sheet2”
End if
I’m sorry that I’m not at a computer with office installed so cant generate the actual code but I think you see where I’m going with this

Related

Automatically expand row heights in Excel when referenced from another sheet

Suppose I am having two sheets where on sheet 1 is this kind of data (different length of information within one row):
It might be lot of text that is "wrapped" to fit in a row (decently)
But, when I try to reference the same text, or try to use some formula for instance INDEX/MATCH to get me the same text, I am failing to get proper ROW Height...so I must adjust manually sheet 2 rows to fit nicely from heights...
Is there a way in Excel to automatically make these row expansions? Without taking a manual action every time because I won't be always sure how long it will be my original text...
You could add something into the Worksheet_Change event
Private Sub Worksheet_Change(ByVal Target As Range)
Target.WrapText = True
Target.EntireRow.AutoFit
End Sub
It might get annoying if it runs after every change for every cell, so you should add more if statements to limit which cells trigger the code.

VBA Range statement using active column

I need to use my active column in my range statements. How to write down this:
Range((Activecolumn)2)
So I need a column value to be dynamic because I am moving left and right by pressing a userform button, but the row number always stays the same. At first I am working with column "C" and select it with
Columns("C").Select
and I navigate the selected column with
Private Sub Next_Format_Button_Click()
ActiveCell.Offset(, 1).EntireColumn.Select
End Sub
So when I navigate to the next column I need all my other range statements to go along with it. So basically the column letter in my range statements should be something like "current" or "active" column.
Could someone, please, help me?
Range(ActiveCell.address).entireColumn.copy
Is what you are looking for I think?
I'd also recommend avoiding ".Select" unless absolutely necessary. It is adding unnecessary lines to your code and leaves the program at greater risk of inadvertent user corruption by selecting another range via mouse before the copy (or whatever) operation completes. Better to go straight to whatever operation you intend to do, or by assigning the range to a variable.
edit: Ah, sorry, I see now your only looking row 2, then its Cells(2, ActiveCell.Column) as pointed out above.
If you want to get the Number of the column where you selected something:
ActiveCell.Column
If you need the letter of the column your selection is in:
Split(ActiveCell.Address, "$")(1)

Excel: if cell value increases -> play sound

I have a cell in excel that increases randomly through the day. This is an API from my trading platform which counts the total number of trades a day.
What I need to do is the following:
Build an IF statement that each time this cell value increases it plays a sound.
I have the sound part covered with a Macro I found online. But the IF statement is giving me trouble.
Anyone could help me out?
You can try using the Calculate() event, depending on how the update occurs this may work for you. This needs to be placed in the worksheet's code module - NOT a standard module.
Option Explicit
Private priorVal As Currency
Private Sub Worksheet_Calculate()
Rem Change this range to be the range that needs to be looked at
If Range("A1") <> priorVal Then
Beep
priorVal = Range("A1")
End If
End Sub

How to insert a 1 automatically in an excel cell?

I want to be able to put a value of 1 in an excel cell when it is selected. Cells that are not selected remain blank.
ActiveCell will use the current cell that is selected then, as you can see, it assigns the value of 1 to that cell.
ActiveCell.value = 1
If you would like it to be more modular if it is perhaps occurring many times, then consider having a look at change events here, as suggested by #Tom
I really don't recommend you doing this especially if this is for monitoring your stock and so for this time and this time only I've written it to make it a bit more safer if you're actually to do this BUT I DO NOT RECOMMEND IT.
you're going to need to paste this into the worksheet module that it relates to
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Columns.Count = 1 And Target.Rows.Count = 1 And Target.Column = 2 Then
Target.Value = 1
End If
End Sub
To get to the worksheet module you need to go into the vba editor (Shortcut Alt+F11 on windows) and paste in the correct worksheet module (Notice highlighted sheet)
I warn you though this could very quickly lead to your stock levels being inaccurate as this will run whenever you click on a cell or move around a worksheet with the arrow keys. This could mess up your whole system and there will be no undo (vba wipes the undo memory)
What would be much better to do is actually monitor your exact stock levels in excel, then use a formula such as (say you keep your stock level in column c)
=IF(C1>0, B1=1, B1=0)
This would then automatically accurately represent whether it was in stock or not.

Adding a specific value to a cell every time a number greater than 0 is added to another cell

I would like cell M6 to add $12.73 every time I add a number greater than 0 to M7.
Example:
I am doing payroll. For every day worked (Field M7) I bill $12.73 (Field M6). I do this every month, and need to keep a running list.
Instead of always having to put the number of days in field M7 and then add $12.73 to field M6, I would like the +$12.73 to compute automatically when I add the number of days to M7.
Please advise.
Thanks in advance.
This couldn't be done with formula to the best of my knowledge. You could hypothetically add another cell which you manually increment every time you do something but a more elegant solution would be to use VBA to automatically increment the value of the cell by 12.73.
Take a look at this similar question. Check updates automatically
try this in the sheet that you want, the sheet object "me" will only work if the code is contained there and not in a module. As a side this will also add 1 to the value when the cell is cleared, but it should be enough to get you started:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("A5")) Is Nothing Then Me.Range("B5").Value = Me.Range("B5").Value + 1
End Sub
Put this formula into M6:
=if(M7>0,"12.73","")
Enter your days worked into M7, and M6 will automatically populate 12.73.

Resources