I am using the evaulation function in combination with match function. The first aim is to incorperate the variable which containts the number of the"last row" which is the row that contains the first blank cell, here declared as NextRow into the evaluation function. I have been trying the two variants as depicted below. Somehow it doesn't seems to work. I am sure I have done somewhere a mistake in the combination in the "E1:E & NextRow &" part.
My second question is whether it it possible to stop the search of the evaluation function when it hits its first full match? Meaning, it stops as soon as it find the letters A,B,C in the columns E,F,G and goes no further from then on.
Function E01(……..)
Set NextRow=Worksheets(“Roh“).cells(cells.Rows.count,1).End(xlup).Offset(1,0)
1.) RicRow= Worksheets(“Roh“).Evaluate("match(“““ & A & ““ & B & ““ & C & “““, E1:E & NextRow & F1:F
& NextRow & G1:G & NextRow, 0)“)
2.) RicRow= Worksheets(“Roh“).Evaluate("match(“““ & A & ““ & B & ““ & C & “““, E1:E &
NextRow.Columns("E“) & F1:F & NextRow.Columns("F“) &G 1: & NextRow.Columns("G“) , 0)“)
The answer to the question is below:
RicRow= Worksheets(“Roh“).Evaluate("match(“““ & A & ““ & B & ““ & C & “““, E1:E" & NextRow.Row &" & F1:F" & NextRow & " & G1:G" & NextRow &", 0)“)
Related
I have an SSRS report that is a calendar, and it shows each persons different activity for each day. I currently do this via .vbcrlf to create the line break.
What I would like to do is only return a line break when there is data in the specific value.
My current expression is:
=Fields!DayOfMonth.Value
& Constants.vbcrlf
& Constants.vbcrlf
& Fields!Shift.Value
& Constants.vbcrlf
& Fields!OT.Value
& Constants.vbcrlf
& Fields!Holiday.Value
& Constants.vbcrlf
& Fields!AbsenceType.Value
& Constants.vbcrlf
& Fields!ClockIn.Value
So if there is no Holiday I would like to remove that line and the break meaning Absence and In/Out would move up the text box. I've tried using isNothing but cant get the syntax right.
It sees the data as NULL values, which can alter the way it treats text.
You can use iif(isnothing(Field!Thing.Value), "", Constants.vbcrlf & Field!Thing.Value) around each one to replace null values with blanks.
There may be a more elegant solution available.
The syntax which worked for me in VS 2017 with SQL Server Data Tools:
=IIf(Fields!Holiday.Value Is "", "", Fields!Holiday.Value + Environment.NewLine)
+ IIf(Fields!AbsenceType.Value Is "", "", Fields!AbsenceType.Value + Environment.NewLine)
Code is pretty much self explanatory - if there is no value for Holiday, result is empty string or else if it has value, show value and line break. For latest syntax of any function, just refer to the examples given in the Expression window.
I have a form which has a ComboBox on it that pulls all DISTINCT colleague names from a huge table that includes all of our sales (50k+ records). It works perfectly fine, but it takes 3-4 minutes to open the form because it takes so long for Access to find all unique colleague names in the table.
I've been trying to research this and found something that looks useful, but can't seem to get it right.
The code I have at the moment:
Private Sub CollName_Change()
Dim strText As String
strText = Nz(Me.CollName.Text, "")
If Len(strText) > 2 Then
Me.CollName.RowSource = "SELECT CollPerf.Colleague FROM CollPerf WHERE CollPerf.Colleague LIKE ""*"" & strText & ""*""; "
Me.CollName.Dropdown
End If
End Sub
I found this code on two forums, this is supposed to do the following: "the key is to not have a Row Source defined for the Combo Box. The row source will be defined as the user starts typing letters. Once they get to 3 letters then the row source of the combo box will be defined and the combo box will be told to dropdown."
When I get to 3 letters, a dropdown appears, but it's blank, it doesn't display any results.
I'm relatively new to Access, although already built two databases, but they all have relatively basic SQL queries, so I have no idea what I'm not doing right here.
Any advice? Or alternatively a different solution as to how take my combo box faster and still keep values unique?
You only have some double-quote mixup there. It is much easier to use single quotes instead of double double-quotes.
Me.CollName.RowSource = _
"SELECT CollPerf.Colleague FROM CollPerf WHERE CollPerf.Colleague LIKE '*" & strText & "*';"
But your query would be way faster if you would only use the starting letters, i.e. remove the leading *
Me.CollName.RowSource = _
"SELECT CollPerf.Colleague FROM CollPerf WHERE CollPerf.Colleague LIKE '" & strText & "*';"
But that depends on your requirements.
EDIT to debug:
Dim strText As String
Dim strSelect As String
strText = Nz(Me.CollName.Text, "")
If Len(strText) > 2 Then
strSelect = "SELECT CollPerf.Colleague FROM CollPerf WHERE CollPerf.Colleague LIKE '*" & strText & "*';"
Debug.Print strSelect
Me.CollName.RowSource = strSelect
Me.CollName.Dropdown
End If
Copy strSelect from the Immediate Window into a query, and try it out. It should help resolve the problem.
See How to debug dynamic SQL in VBA
I have tried every combination of paste special and can't figure this one out. I just want to copy the entire row's values, then paste them onto the next sheet. I am extremely close to being finished here, but a few of the cells I loop through have formulas that produce the values and I keep ending up with the lovely "REF" text in my cells.
Dim bottomL As Integer
bottomL = Sheets("Final Body Assembly List").Range("B" & Rows.Count).End(xlUp).Row
Dim c As Range
For Each c In Sheets("Final Body Assembly List").Range("B1:B" & bottomL)
If c.Value >= 1 Then
c.EntireRow.Copy Worksheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next c
End Sub
New here and VERY new to VBS so please easy.
I have a set of files that are sent via FTP to a folder on a server, the naming structure of these files are:
waw_29_2013-09-09_act_v001.csv
waw_29_2013-09-09_amf_v001.csv
waw_29_2013-09-09_inc_v001.csv
waw_29_2013-09-09_nbs_v001.csv
waw_29_2013-09-09_trn_v001.csv
waw_29_2013-09-09_val_v001.csv
waw_29_2013-09-09_wth_v001.csv
What I am trying to achieve is for a script to scan the folder that contains these files, and change the name to the previous day but keep the structure of the naming convention.
I have tried this on a file in my c:\ drive (I am very new so please excuse my lack of understanding)
**Dim file1, file2
file1 = "C:\fake_%date%.txt"
file2 = "C:\waw_" & year(date) & -month(date) & -Day(Date) & "_act_v001.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file1) = true then
If fso.FileExists(file2) = true then
fso.DeleteFile(file2)
End if
fso.MoveFile file1, file2
'else
' msgbox "File does not exist"
End If
Set FSO = Nothing**
The is on a file (as a test) called c:\fake_2013-09-09.txt and it is trying to scan the c:\ drive for that file (regardless of the date) and then rename this file to "waw_29_2013-09-09_act_v001.csv"
.
I also need the same script to run separately but to change the date back 3 days for weekends too.
Any help would be hugely appreciated.
Take care
Mike
Hello again
I have gotten a little further:
I have now amended the script to look as follows:
Dim file1, file2
file1 = "C:\winter\waw_29_2013-09-10_act_v001.csv"
file2 = "C:\winter\waw_29_" & -Year(Date) & Right("0" & Month(Date),2) & Right
("0" & -Day(Date),2) & "_act_v001.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file1) = true then
If fso.FileExists(file2) = true then
fso.DeleteFile(file2)
End if
fso.MoveFile file1, file2
'else
' msgbox "File does not exist"
End If
Set FSO = Nothing
Now I have 2 questions about the script as I think it is 90% there:
The line in File1, how can I get this to search for the file but to only search on the and _act field?
Under File2, I can get the system to now produce a date for the file (the wrong date but I am getting there) but the format is 20130909 and not 2013-09-09 as I need. How do I add in the "-" between dates as it fails if I leave the "& Right("0")" in to create the leading "0" but if I take that out, it will put the "-" in but no leading )!!!
My last question is I have found the DateAdd command that allows me to search the file and then change the date to the previous date.....my problem is I don't know where to put that in the code.
Guys if you can help, I would be really grateful.
Mike
WOW thank you so much, really helped a lot and solved the second part of my issue.
Do you know how to search a folder for a set parameter so I can search a folder named "waw_29_2013-09-09_act_v001.csv" but to exclude the date section from the search?
Again thank you so much, I learnt a lot from that part of the script
Mike
For building a date string of the form YYYY-MM-DD you need to concatenate the date portions and the interleaving hyphens:
d = Date
Year(d) & "-" & Right("0" & Month(d), 2) & "-" & Right("0" & Day(d), 2)
For building a date string of 3 days ago you do the same, but subtract 3 days from the current date first:
d = Date - 3
Year(d) & "-" & Right("0" & Month(d), 2) & "-" & Right("0" & Day(d), 2)
I use OS X Mountain 10.8.2.
I used Automator and added AppleScript, copying the command from the old app's developer at the Iconoodle - Convenient ICNS to PNG image conversion (Iconoodle isn't supported by OS X 10.8 by being a PPC app). I saved the workflow as an application. I selected the images and dropped them into the application, but the images weren't converted to ICNS. I also copied from the question Convert image to .icns file AppleScript Obj-C and it didn't work either.
I'm really frustrated with it. I want to use Automator to convert the multiple images from PNG to ICNS once at all. It's very annoying to convert each image to ICNS in the icon editor applications, one for one. The Preview.app doesn't want to convert the image in format PNG to ICNS because it has only one page, it can convert it to ICNS only if the icon has many pages.
Do you know to make it?
Thank you for your attention, help and patience!
Here is another approach...
NOTE: Your ORIGINAL pngs will be scaled to the expected size before the icns file is created. If you want to keep a copy of the original png, duplicate it first. You can also add a line or so to the script to do so automatically.
property expectedSizes : {16, 32, 48, 128, 256, 512, 1024, 9999999}
set myFiles to choose file with multiple selections allowed
repeat with aFile in myFiles
tell application "System Events" to set bPath to POSIX path of (container of aFile)
set newPath to bPath & "/" & bName(aFile) & ".icns" as text
set aFile to quoted form of (POSIX path of aFile)
set {W, H} to {paragraph 1, paragraph 2} of (do shell script "sips -g pixelWidth -g pixelHeight " & aFile & " | grep -Eo [0-9]*$")
set {W, H} to {W as number, H as number}
if W > H then
set W to eSize(W)
do shell script "sips " & aFile & " -Z " & W & " -p " & W & space & W & " --padColor FFFFFF -i"
delay 1
else if H > W then
set H to eSize(H)
do shell script "sips " & aFile & " -Z " & H & " -p " & H & space & H & " --padColor FFFFFF -i"
delay 1
-- H = W but not in expected sizes
else if H is not in expectedSizes then
set H to eSize(H)
do shell script "sips " & aFile & " -Z " & H & " -p " & H & space & H & " --padColor FFFFFF -i"
delay 1
end if
do shell script "sips -s format icns " & aFile & " --out " & quoted form of newPath
end repeat
on bName(theFile)
tell application "Finder" to set {name:fileName, name extension:nameExtension} to theFile
set baseName to text 1 thru ((get offset of "." & nameExtension in fileName) - 1) of fileName
end bName
on eSize(lDimen)
repeat with i from 1 to 8
if lDimen < item i of expectedSizes then return item (i - 1) of expectedSizes
end repeat
end eSize
You can still run the iconoodle script by just pasting it to AppleScript Editor. It's just a wrapper for sips, but it can only convert icns to png.
You can use sips directly to convert png to icns:
for f in *.png; do sips -s format icns "$f" --out "${f%png}icns"; done