Excel : quick and dirty script to change values in a spreadsheet

December 23rd, 2011

just a quick and dirty script to quickly blank out columns in a spreadsheet.

Sub clearout()
Dim rng As Range, row As Range, cell As Range
Set rng = Range(”I12:K33″)

For Each a In rng.Rows
For Each cell In a.Cells

cell.Value = “”
Next
Next
Set rng = Range(”C12:C33″)
For Each cell In rng.Cells

cell.Value = “”
Next
End Sub

Import active python modules from a folder.

July 26th, 2011

http://www.faqs.org/docs/diveintopython/odbchelper_divein.html
downloaded the file and then put it into a folder. c:\temp\python\ in my case with the commands:

>> import sys
>> sys.path.append(’c:\\temp\\python\\’)

MS Excel funny annoyance : can’t open worksheet in a new window (part 1)

May 30th, 2011

Here is a funny annoyance from MS Excel 2003/2007. When I click on windows explorer or
Sharepoint links to open excel files, they randomly open in the same instance of excel or they open in their own excel instance. So I took the liberty of producing a solution which does just that. Creating a button which pushes the selected worksheet “out” into a new Excel instance.

Here are some forseen issues:
- there needs to be a button in excel to activate the action
- Macro security
- error checking for read-only

excel vba : for loop cross cell copying

April 27th, 2011

quick assignment taking the value from a formulated cell to another and copying it to another and for loop it.

For i = 68 To 100
Range(”i” & i) = Range(”k” & i)
Next i

EDI datetime formats

April 6th, 2011

It seems X12 and EDIFACT are fairly equivalent regarding dates.
An example of the newer X12 standards for dates would be Data Element 1250
and how it defines the next element; 1251 (The actual date being reported).

Some of the valid values for DE1250 are:

CC – First two digits of the year expressed in the format CCYY (length of 2)

CM – Date in Format CCYYMM (length of 6)
CY – Year Expressed in Format CCYY (length of 4)
D6 – Complete Date expressed in the format YYMMDD (length of 6)
D8 – Complete Date expressed in the format CCYYMMDD (length of 8)
DB – Date Expressed in Format MMDDCYY
DD – Day of Month in Numeric Format (length of 2)
DT – Date and Time Expressed in Format CCYYMMDDHHMM (length of 12)
MD – Month of Year and Day of Month in Format MMDD (length of 4)
MM – Month of Year in Numeric Format (length of 2)
TM – Time Expressed in Format HHMM (length of 4)
TS – Time Expressed in Format HHMMSS (length of 6)
YM – Year and Month Expressed in Format YYMM (length of 4)
YY – Last two digits of Year Expressed in Format CCYY (length of 2)
RD2 – Range of Years Expressed in Format YY-YY (length of 5)
RD4 – Range of Years Expressed in Format CCYY-CCYY (length of 9)
RD5 – Range of Years and Months Expressed in Format CCYYMM-CCYYMM (length of
13)
RD6 – Range of Dates Expressed in Format YYMMDD-YYMMDD (length of 13)
RD8 – Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD (length of 17)
RDM – Range of Dates Expressed in Format YYMMDD-MMDD (length of 11)
RDT – Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM
(length of 25)
RMD – Range of Months and Days Expressed in format MMDD-MMDD (length of 9)
RTM – Range of Time Expressed in Format HHMM-HHMM (length of 9)

DE1251 is a 35 byte alpha-numeric field.

optimizing vista

December 15th, 2010

An article I used to optimize Windows Vista running on my little UMPC. Since I primarily use this computer at home, I disabled a number of services which allowed it to run significantly faster.

http://www.optimizingpc.com/vista/optimizing_windows_services.html

disabling aero also helps
http://www.howtogeek.com/howto/windows-vista/disable-aero-on-windows-vista/

MS Access VBA : outputing each record to a new text file

September 30th, 2010

So I recently had to come up with a pretty quick and dirty way to export each record out of a database into a text file. each record was a broken down email which needed to be output’d to its whole self again.

below is the code written in vba:

Private Sub Command65_Click()
Dim strSql As String
Dim strSubject As String
Dim strEmailBody As String
Dim fso As New FileSystemObject
Dim i As Integer
Dim ts As Object
Dim rst As Recordset
Set fso = CreateObject("Scripting.FileSystemObject")

strSql = "select top 10 i.uiditem, i.strEmailSubject, i.strEmailBody from tblpcs_ch_entitybin e inner JOIN tblkepsitem i on e.uidcollection = i.uidcollection and e.uiditem = i.uiditem where e.chbinno like 'SUBJECT MISSING"

Set rst = CurrentDb.OpenRecordset(strSql, dbOpenDynaset, dbSeeChanges)
'rst.MoveLast
i = 0
Do Until rst.EOF

strSubject = "Subject: " & rst!strEmailSubject & vbCr & vbNewLine & rst!strEmailBody
Set ts = fso.CreateTextFile("c:\temp\" & i & ".txt", True)
ts.Write strSubject
ts.Close
Set ts = Nothing

'MsgBox (strSubject)
i = i + 1
rst.MoveNext
Loop

End Sub

deactivate google voice forwarding

September 24th, 2010

Wireless Carrier or Network —> Deactivation Code
AT&T Cingular, T-Mobile, GSM network: ##004#

Verizon (CDMA network): *73 AND *900 AND *920

Verizon (TDMA Network): *740 AND *730

Bluegrass Cellular: *900 AND *920

Cellcom: *680

Cincinnati Bell: ##004#

US Cellular: *740

forwarding cell phone to google voice

September 24th, 2010

AT&T Cingular, T-Mobile, GSM network: *004*1[GVnumber]*11#

Verizon (CDMA network): *71[GVnumber] AND *90[GVnumber] AND *92[GVnumber]

Verizon (TDMA Network): *74[GVnumber] and *73[GVnumber]

Bluegrass Cellular: *90#[GVnumber] and *92#[GVnumber]

Cellcom: *68[GVnumber]

Cincinnati Bell: *004*[GVnumber]#

US Cellular: *74[GVnumber]

Crystal Reports : counting occurance of characters in a string

August 31st, 2010

crystal-report_occurance

Say you wanted to count the number of occurances in a string.. like say an “x”. how would you do that in crystal reports:

Here is a small snippet on figuring that out.

local numberVar count:= 0;
local stringVar name := "xxxyyyx";
Local numberVar strLen:=length(name);
local numberVar I;
for i:=1 to strLen do
If Mid(name,i,1)= "x"
then count := count +1;
count