In this workboook:
Thursday, March 29, 2012
PAste value only for Ctrl -V
Posted by AG at 1:56 AM 0 comments
Labels: Ctrl + V, Macro, paste value only
Wednesday, March 28, 2012
Excel Paste Value only
http://www.mrexcel.com/archive/VBA/4522.html
Posted by AG at 6:53 PM 0 comments
perl 2 array
my @num = qw (1 2 3 4 5); my @alp = qw (A B C D E); #One way for my $index (0 .. $#num) { print "$num[$index]-$alp[$index]\n"; } #Or print "$num[$_]-$alp[$_]\n" for (0 .. $#num);
Posted by AG at 12:20 AM 0 comments
Monday, March 26, 2012
file and dirhandle for perl
Posted by AG at 12:07 AM 0 comments
Wednesday, March 21, 2012
Posted by AG at 11:12 PM 0 comments
Labels: Perl
Tuesday, March 20, 2012
Posted by AG at 8:29 PM 0 comments
Posted by AG at 8:28 PM 0 comments
macro vba, remove all merge cell
Posted by AG at 12:51 AM 0 comments
Labels: Macro
Monday, March 19, 2012
merge cell vba macro
Posted by AG at 8:57 PM 0 comments
Labels: Macro, merge cell
Friday, March 16, 2012
PAste value but not paste special
Posted by AG at 1:52 AM 0 comments
Tuesday, March 13, 2012
Delete hidden rows
Sub DeleteHiddenRows_Workbook() 'This Microsoft Excel Macro will remove hidden rows from End Sub
'all worksheets in a workbook.
For i = 1 To Worksheets.Count
If Worksheets(i).Visible Then
Worksheets(i).Select
ActiveCell.SpecialCells(xlLastCell).Select
k = ActiveCell.Row
For j = 1 To k
If Rows(j).Hidden Then
Rows(j).Hidden = False
Rows(j).Delete
End If
Next j
End If
Next i
If Worksheets(1).Visible Then Worksheets(1).Select
Posted by AG at 1:49 AM 0 comments
Labels: delete hidden rows, Macro
determine row/ column is hidden
Range(“A1″).ColumnWidth = 0 Or Range(“A1″).RowHeight = 0
Range(“A1″).EntireColumn.Hidden Or Range(“A1″).EntireRow.Hidden
Posted by AG at 1:39 AM 0 comments
Prevent user from delete worksheet
method 1:
Private Sub Worksheet_Activate()
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=847)
Ctrl.Enabled = False
Next Ctrl
End Sub
Private Sub Worksheet_Deactivate()
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=847)
Ctrl.Enabled = True
Next Ctrl
End Sub
----------------------------------------------------------------------------------------------------------------
Method 2:
Option Explicit
Private Sub Workbook_Activate()
Call Workbook_SheetActivate(ActiveSheet)
End Sub
Private Sub Workbook_Deactivate()
Call Indel
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ActiveSheet.Name = ("Data") _
Or ActiveSheet.Name = ("Query") _
Or ActiveSheet.Name = ("Sheet1") Then
Outdel
Else
Indel
End If
Next ws
End Sub
Private Sub Outdel()
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=847)
Ctrl.Enabled = False
Next Ctrl
End Sub
Private Sub Indel()
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=847)
Ctrl.Enabled = True
Next Ctrl
End Sub
----------------------------------------------------------------------------------------------------------------
Method 3:
Private Sub Worksheet_Activate()
Dim CB As CommandBar
Dim Ctrl As CommandBarControl
For Each CB In Application.CommandBars
Set Ctrl = CB.FindControl(ID:=847, recursive:=True)
If Not Ctrl Is Nothing Then
Ctrl.OnAction = "RefuseToDelete"
Ctrl.State = msoButtonUp
End If
Next
End Sub
Private Sub Worksheet_Deactivate()
Dim CB As CommandBar
Dim Ctrl As CommandBarControl
For Each CB In Application.CommandBars
Set Ctrl = CB.FindControl(ID:=847, recursive:=True)
If Not Ctrl Is Nothing Then Ctrl.OnAction = ""
Next
End Sub
Private Sub ResetDelete()
Dim CB As CommandBar
Dim Ctrl As CommandBarControl
For Each CB In Application.CommandBars
Set Ctrl = CB.FindControl(ID:=847, recursive:=True)
If Not Ctrl Is Nothing Then
Ctrl.Reset
Next CB
End Sub
'put in standard module
Public Sub RefuseToDelete()
MsgBox "This worksheet should not be deleted!", _
Buttons:=vbExclamation, _
Title:="Cannot Deleteworksheet!"
End Sub
Posted by AG at 12:36 AM 0 comments
Labels: Macro, Prevent user from delete worksheet, VBA
Sunday, March 11, 2012
Add-ins tab of the Ribbon
Posted by AG at 8:44 PM 0 comments
Labels: Add-in macros, Add-ins tab of the Ribbon, Macro
find word funtion for macro vba
Posted by AG at 7:57 PM 0 comments
search text in excel cell
myint=instr(1,activecell.value,"Abc")
which is going to return a number to where "Abc" starts
if myint > 0
text found.
----------------------------------------------------------------------
Function TextSearch(ByVal strSearchFor, ByVal Target As Variant) As Boolean
Dim OneCell As Range
TextSearch = False
If TypeName(Target) = "Range" Then
For Each OneCell In Target
If InStr(1, OneCell.Text, strSearchFor, vbTextCompare) > 0 Then
TextSearch = True
Exit For
End if
Next OneCell
ElseIf TypeName(Target) = "String" Then
If InStr(1, Target, strSearchFor, vbTextCompare) > 0 Then TextSearch = True
End If
End Function
------------------------------------------------------------------------------
Posted by AG at 7:27 PM 0 comments
http://www.ozgrid.com/forum/showthread.php?t=115687
Option Explicit
Sub Bold1stWord()
Dim rCell As Range
With Selection
.Cells.Copy
.Cells.PasteSpecial xlValues
Application.CutCopyMode = False
For Each rCell In .Cells
rCell.Characters(1, InStr(1, rCell, ":") - 1).Font.Bold = True
Next rCell
End With
End Sub
Posted by AG at 3:26 AM 0 comments
extract 1 word in cell for macro vba
http://www.teachexcel.com/free-excel-macros/m-138,udf-get-first-word-cell-excel-free-macro.html
Function GETFIRSTWORD(Text As String, Optional Separator As Variant)
Dim firstword As String
If IsMissing(Separator) Then
Separator = " "
End If
firstword = Left(Text, InStr(1, Text, Separator, vbTextCompare))
GETFIRSTWORD = Replace(firstword, Separator, "")
End Function
Posted by AG at 3:22 AM 0 comments
Tuesday, March 6, 2012
Excel Macro, VB
http://spreadsheetpage.com/index.php/file/C36/P20/
http://spreadsheetpage.com/index.php/files
- spreadsheet page with different macro and VB program, userform
http://spreadsheetpage.com/index.php/tip/C29
http://spreadsheetpage.com/index.php/tip/displaying_a_menu_of_worksheets_to_print/
tips
http://spreadsheetpage.com/index.php/tips
Posted by AG at 1:38 AM 0 comments
Labels: Excel, Macro, VBA UserForms and ActiveX Controls