Showing posts with label macro. Show all posts
Showing posts with label macro. Show all posts

Wednesday, August 17, 2011

UserForm resizer

I recently use below codes to make Userform in Excel resizeable:

'Done in Excel
Private Sub SetFormStyle()

Dim lStyle As Long, hMenu As Long

'Have we got a form to set?
If mhWndForm = 0 Then Exit Sub

'Get the basic window style
lStyle = GetWindowLong(mhWndForm, GWL_STYLE)

'Build up the basic window style flags for the form
SetBit lStyle, WS_CAPTION, mbCaption
SetBit lStyle, WS_SYSMENU, mbSysMenu
SetBit lStyle, WS_THICKFRAME, mbSizeable
SetBit lStyle, WS_MINIMIZEBOX, mbMinimize
SetBit lStyle, WS_MAXIMIZEBOX, mbMaximize

Saturday, August 13, 2011

Search 3 Keywords Once

Hi,

Recently I'm working for someone , he asked me to search 3 keywords once.
here is the codes:

userform













Private Sub CommandButton1_Click()
    Dim Kw, Xkw, Xsrc, Wkn As Worksheet, i, X, Wk1 As Worksheet, Txt As Variant
   
    If MsgBox("Do you want to copy results to a new sheet ? ", vbYesNo) = vbNo Then End
 
    Set Wk1 = Sheet1
    Set Wkn = Worksheets.Add(, Sheet1)
 
    Wk1.Activate
    Txt = Split(Replace(TextBox3.Text, Chr(32), ""), Chr(44))
 

Thousands pictures to your sheet

Several days ago I get a job from a good man, he ask me to put his thousands pics to his worksheet. Until I do this to my macro:

Sub INSERTPics()
Application.ScreenUpdating = False
On Error Resume Next
For i = 2 To 174
ActiveSheet.Pictures.Insert( _
"c:\Mr.BrownsPics\" & Cells(i, 3) & ".jpg").Select
With Selection.ShapeRange
.Top = Cells(i, 2).Top + 0.5
.Left = Cells(i, 2).Left + 0.5
.Width = Cells(i, 2).Width - 1
.Height = Cells(i, 2).Height - 1
.Name = Cells(i, 2)
End With
[A1].Select
If Err.Number > 0 Then
Cells(i, 2) = "nopic"
End If
Next i
Application.ScreenUpdating = True
End Sub

NOTE: Make sure that column "C" contains the names of the files.

Monday, August 1, 2011

Works fine on my Excel with Userform

Now I have new ms-excel that I’ve copied this codes from Vb-project.com thanks to programer…, I do copy to this:
This description only touches on the most interesting parts of the program. Download it to see the details.You can click the links on the WebBrowser to navigate to a Web page, or enter a URL and click the Go button to navigate there. The following code shows how the program navigates.
Private Sub cmdGo_Click()
    On Error GoTo BadNavigate
    wbrWebSite.Navigate txtUrl.Text
    Exit Sub

Good for Spreadsheet automation - VBA

Some people do spreadsheet difficultly, there is a good news for newbie in excel work.

I do Excel work manually few years ago until I meet this VBA way to get automation ie. using recursive routine or procedure to do same process often.

I do with userform in excel, my senior said that "No way you use that silly idea, this will spend more time to build!" , than I just do it by learning how does it work.

I believe that automation will help my work at the office. But, userform standard cannot resize until I found code to make it resizeable by put some code as Classmodule. Then I do my work now easily.


You can put your PASSWORD:

see too: