copy/paste row with event 1 row down and create new event on top of former row with event. The events themselves are text - copy

I hope you will be able to help me.
I need to do the following in Excel:
a. Newest event comes on top and the former event moves 1 row down (below), and;
b. After newest event has been copied and pasted to 1 row down, the first row is clear of any data (blank cells);
c. Now a new event comes on top of the former event. If there is also a new date involved than everything the old events and dates moves at least 2 rows down and leaves a blank row in between. And so on until a full month has been reached;
d. After that the entire sheet/month is copied to an archive.
I've been trying to write the code for this in VBA, but thus far it's not working. To be honest, I can't code and I've trying to do this through youtube and everything I can find online.
I would greatly appreciate any help I can get on this one. I'm new here so I can't a picture just yet. Hopefully somebody understands my questions.
Again thanks for any help on this one.
enter image description here
The picture describes pretty much how I want this to work

I'm answering my own questions, because I sort figured it out and I'm really excited. So the code is not perfect, I know but it works :)
There are two type of code running:
1.
Sub MoveCopyRows()
'Copy and Paste Row
Range("10:10").Copy
Range("11:11").Insert
End Sub
And
2.
Sub CutInsertSheet()
'Cut or Copy and Paste to another worksheet
Worksheets("Overdracht").Range("11:35").Cut
Worksheets("Berichtenhistorie").Range("6:6").Insert
Application.CutCopyMode = False
End Sub
This coding has got me hooked. Now I'm going to see, if I can combine them and if I would be able to change the cell color automatically after adding a new row. Wish me luck everybody! :) And before I forget, thx everybody for your help!

Related

How to get the content in the table within a CVirtualGridCtrl control of a window through pywinauto

I am trying to get the content of a table within a GridCtrl control as shown in the screenshot below.
I have found through spy++ that the control containing the table is CVirtualGridCtrl.
But how can I get the content of the table?
app = pywinauto.Application().Connect(path = "xiadan.exe")
control = app[u'网上股票交易系统5.0'].CVirtualGridCtrl
control.PrintControlIdentifiers()
If I run the above code, I will get the following output:
Having searched and test for a long time, I still have no clue.
Could someone kindly give me a hint? Thanks a lot.
Edit:
Really appreciate your quick response #vasily-ryabov. I have tried as you suggested, unfortunately there is no recognizable control to get the numbers I want.
Does this mean that it is then impossible to get the content of the cells?
I have also tried right clicked on the control, but there is no interested short-cut operation.
You can try to use clipboard to get grid data.
control.type_keys('^A^C')
data = pywinauto.clipboard.GetData()

LibreOffice BASIC function - Copy if over a value to a new sheet

I'm trying to create a simple function on a LibreOffice Calc sheet.
I have a table of information where cells A1:K2 has headings (the cells in Row 2 are merged)
all the information runs from A3:K176
The sheet has various functions running on it already, all I need is one more function.
At first I wanted it to automate when i open, but then i thought running the BASIC macro off of a button might be better, so i can edit and then just hit the button once I'm done.
I have the button linked up to run the macro already, but now im stuck... I have tried many ways of writing the code, but it seems that i am just too green to figure it out.
the last time i ran Excel advanced functions i was in high school.
ok, enough talking...
All I need the macro to do is once I hit the button, I need it to check column K and any value > 1 it needs to take that whole row and copy it then go to a target sheet, clear any data on the target sheet. then copy that set of rows to the next open row in the target sheet. possibly even exporting the result to a .txt file as a bonus.
this is a start...
in future I would like to add another button that will do the same function to a array lower down and put that into a different sheet.
Option Compatible
Sub SWD_AwakeningsTrade
Dim i, LastRow
LastRow = Sheets("Card_List").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Awakenings For trade").range("A2:I500").clearContents
For i=2 to LastRow
If Sheets("Card_List").Cells(i,"K").Value = "(>1)" Then
Sheets("Card_List").Cells(i, "K").EntireRow.Copy
Destination:=Sheets("Awakenings For trade").Range("A" & Rows.Count.end(xlUp)
End if
next i
End Sub

powerpoint run macro every time presentation hits first slide

I am have a macro running in my powerpoint presentation (2007) to update all of the linked excel data. The macro works perfectly if I run it manually but I am trying to set it to run automatically every time the presentation gets back to the first slide.
I put the following code together after looking through a few similar questions here but it doesn't seem to work. Nothing happens when I hit slide 1.
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = 1 Then
Dim osld As Slide
Dim oshp As Shape
On Error Resume Next
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
oshp.LinkFormat.update
Next oshp
Next osld
End If
End Sub
anyone have any ideas?
Your code seems correct and should work, but PowerPoint sometimes doesn't properly implement OnSlideShowPageChange.
Adding an ActiveX control to the slide (even off-slide) usually solves the problem.

Unity/NGUI Updating List at runtime

I was wondering if someone could explain to me how I update a list at runtime in Unity?
For example I have a spell book, which has 3 spells in it, when I drag them to my action bar they get re-parented to it, what I'm trying to do is get a list of each child under the actionbar transform,
My problem is where to actually do something like this if I try something like below in the update, it adds whatever's there many times, which I can understand since update runs every frame..
list = actionbarui.GetComponent(UIGrid).GetChildList();
for(var i =0;i < list.size; i++)
{
buttonList.Add(list[i].gameObject);
}
If I add a callback to the buttons so that whenever they're drag and dropped it runs the above code and add thing's additively, as in, if you drag just one "spell" on it will loop through once, which is fine, but as soon as you add another it loops through three times, that is, it already has one it then adds the same one again PLUS the new button that's just been dragged on for a total of 3.
I've tried changing the code to
list = actionbarui.GetComponent(UIGrid).GetChildList();
for each(var child : Transform in list.GetEnumerator())
{
buttonList.Add(child.gameObject);
}
But this simple doesn't add anything, I am unsure how to go about keep the lists update as they are dragged off and on, could anyone please explain how this is achieved?
Please ignore the second "list" code, it's implementing "BetterLists" as apart of NGUI, so doesn't follow standard list methods.
Thank you for reading
If I add a callback to the buttons so that whenever they're drag and dropped it runs the above code and add thing's additively, as in, if you drag just one "spell" on it will loop through once, which is fine, but as soon as you add another it loops through three times, that is, it already has one it then adds the same one again PLUS the new button that's just been dragged on for a total of 3.
That is the expected result here. You are running through the list of children and adding them to your buttonlist, so first time there is only one item to add, then when you add another child there are two items to add, thus resulting in three items.
Either don't have a for loop and do:
buttonList.Add(the_GameObject_that_was_just_added_to_the_bar);
Or clear your buttonList before the for loop:
list = actionbarui.GetComponent(UIGrid).GetChildList();
buttonList.Clear();
for(var i =0;i < list.size; i++)
{
buttonList.Add(list[i].gameObject);
}
Alternatively to Dover8's response, you can first check if the buttonList already contains a reference to the child to be added. If it does, continue. Otherwise add the new child.
However, given the expense of doing the checks, and since you are already looping through the list already, I'd recommend that you follow his suggestion to clear the list before running the loop. It will probably give you the best performance out of these examples.
If there's a reason you can't or shouldn't clear the buttonList, and you still need to run through it, I'd recommend my suggestion. It really depends on which implementation works best for what you are trying to do. The point is that there are several ways to do this, and they have different performance profiles you need to consider.

QCompleter and Tab key

I'm trying to make a Completion when pressing tab, you get the first completion of all possibilities.
But, in a QWidget-based main window, pressing tab will make that QLineEdit lost focus, and completion popup hides after that.
Is there a way to fix it ?
Have you tried to subclass QLineEdit and intercept the key press event?
Alternatively you could set up an event filter.
Whew. It took me some time to figure this out :) Multiple times I have tried to solve this problem, but always gave up. Now, I dug enough to find the answer.
OP, please pardon me, because the code here is Python, but should be understandable and work for C++ as well.
Basically, the problem I had was "how to select an entry in the QCompleter"; I didn't notice before, but the answer is in the popup() method. QCompleter works with a model and a view, which contains the things to show.
You can change the current row as you wish, then get the index of that row in the model, then select it in the pop-up.
In my code, I subclassed QLineEdit, created a tabPressed signal which is emitted every time Tab is pressed. Then, connected this signal to a method of the same class which does this:
get the current index;
select the index in the popup;
advance to the next row.
As implementation, this is very trivial, but for my current purpose this is enough. Here's the skeleton (just for the tab part, it's missing the model and everything else).
class MyLineEdit(QLineEdit):
tabPressed = pyqtSignal()
def __init__(self, parent=None):
super().__init__(parent)
self._compl = QCompleter()
self.tabPressed.connect(self.next_completion)
def next_completion(self):
index = self._compl.currentIndex()
self._compl.popup().setCurrentIndex(index)
start = self._compl.currentRow()
if not self._compl.setCurrentRow(start + 1):
self._compl.setCurrentRow(0)
def event(self, event):
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Tab:
self.tabPressed.emit()
return True
return super().event(event)
You may need to adjust/fix few things, but this is the basic idea.
EDIT:
For details see
http://www.qtcentre.org/threads/23518-How-to-change-completion-rule-of-QCompleter
There's a little issue: when Return is pressed, the things don't work properly. Maybe you can find a solution to this problem in the link above, or in the referenced resources therein. I'll fix this in the next few days and update this answer.
There is probably a better solution but one that comes to mind is to change the focus policy for all other widgets on the form to something that doesn't include "tab" focus. The only options that don't use the tab key are Qt::ClickFocus and Qt::NoFocus.