Showing posts with label excel. Show all posts
Showing posts with label excel. Show all posts

Tuesday, May 5, 2026

How to copy active cell in excel - VBA - How to copy and fill color of row in excel- VBA -Macro - macro copy and color change

ActiveCell.Copy

or

 Sub Macro1()

ActiveCell.Copy

ActiveCell.EntireRow.Interior.Color = 5296274

End Sub


or

 Sub Macro1()

ActiveCell.Copy

With ActiveCell.Row.Interior

        .Pattern = xlSolid

        .PatternColorIndex = xlAutomatic

        .Color = 5287936

        .TintAndShade = 0

        .PatternTintAndShade = 0

    End With

End Sub


ref:- https://www.mrexcel.com/board/threads/vba-command-for-copying-active-cell-content-only.978747/

https://www.reddit.com/r/excel/comments/axgoth/vba_code_to_color_a_row_whole_up_until_a_certain/



Friday, April 10, 2026

select random range cell copy in vba excel - copy random cell in excel macro

 Sub Macro3()

    Dim Rng As Range

    Dim randomIdx As Long

   

    ' Set your target range

    Set Rng = Range("K3:K4591")


    ' Initialize the random number generator

    Randomize


    ' Generate a random index between 1 and the total number of cells

    randomIdx = Int(Rnd * Rng.Cells.Count) + 1

    

    ' Select the cell at that index

    Rng.Cells(randomIdx).Select

     Selection.Copy

End Sub


Thursday, January 22, 2026

Sorting in Excel - Unique records in Excel

For Sorting

 > First Select the columns

> Click on Data Menu

> Click on Sort

> Select the Column (Sort By)

> Click on OK

==============================

For Unique Records

> First Select the column

> Click on Data

> Click on Advanced

> Check on Unique Records 

> Click on OK



ref:- https://support.microsoft.com/en-us/office/filter-for-unique-values-or-remove-duplicate-values-ccf664b0-81d6-449b-bbe1-8daaec1e83c2

Wednesday, January 14, 2026

How to view two books in Excel - How to view two books in excel

 > In excel, there are books.

> And In books there are sheets

------

> At the top,  you have restore option.

> In View Menu, You have arrange all button. You can click on that button.

> You can also used split button

Friday, January 9, 2026

Two filters in excel - Two Columns filters in excel - Multiple Columns filters in excel

> Open Excel

> Click on Data Menu

> Select the columns in sequence, not using CNTL(Column 1,2,3,4) will be used for Multiple columns. (Columns 4,6,9) will not be used for Multiple Columns.

> Click on Filter

> 


Monday, December 29, 2025

Single left click in VBA - Excel

 


    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

    Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)



' Define the mouse events

Public Const MOUSEEVENTF_LEFTDOWN = &H2

Public Const MOUSEEVENTF_LEFTUP = &H4

Public Const MOUSEEVENTF_ABSOLUTE = &H8000

Public Const MOUSEEVENTF_MOVE = &H1


Sub SimulateLeftClick(ByVal x As Long, ByVal y As Long)

    ' Move the cursor to the specified coordinates (screen coordinates)

    SetCursorPos x, y

    

    ' Perform the left click (Down and then Up)

    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0

    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

End Sub


Sub TestClick()

    ' Clicks at screen coordinates X=50, Y=50

    Call SimulateLeftClick(40, 200)

End Sub


Monday, December 22, 2025

Excel Shortcuts - Merging of Two cells

CTRL + E----- To merge two cells


ALT + H +O +I ----------- Column width Auto size

ALT +H + W   or ALT + H + O +A  ---------- Auto size column height


Wednesday, December 10, 2025

How to copy and paste in notepad excel with Arrow VBA

 Sub CommandButton1_Click()


    Shell "Notepad.exe", vbNormalFocus


    Dim I As Integer


    SendKeys "one"


    SendKeys "{Enter}"

     Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "^a"

     Application.Wait (Now + TimeValue("00:00:01"))

     SendKeys "^c"

     Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "{right}"

 Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "two"

 Application.Wait (Now + TimeValue("00:00:01"))

End Sub


or without interval of time


 Sub CommandButton1_Click()

   Shell "Notepad.exe", vbNormalFocus

Application.Wait (Now + TimeValue("00:00:03"))

    Dim I As Integer

 Dim z As Integer

For z = 1 To 50

    SendKeys "one"

    SendKeys "{Enter}"

    SendKeys "^a"

   SendKeys "^c"

    SendKeys "{right}"

    SendKeys "two"

  Next z

End Sub



How to send up and down keys in Excel or VBA

 https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/sendkeys-statement

How to open notepad with for loop and enter a to z characters in excel automatically - alphabets in excel

 Sub SendAlphabet_AtoZ()


Shell "Notepad.exe", vbNormalFocus

    Dim i As Integer

    Dim char_code As Integer

    Dim current_char As String

    Dim row_num As Integer

    

    

     Dim z As Integer


For z = 1 To 50

    row_num = 1

    ' Loop through ASCII codes for lowercase 'a' (97) to 'z' (122)

    For char_code = 50 To 122

        ' Convert the ASCII code to a character

        current_char = Chr(char_code)

        Application.Wait (Now + TimeValue("00:00:00"))

        ' Place the character in the active worksheet in column A

         SendKeys current_char

        

        ' Move to the next row

        

    Next char_code


Next z

  

End Sub

How to count status in selected sheet open or close

 =Countif('SheetName'!I3:I998, "Open")


I3:I998 is range 

Tuesday, November 25, 2025

How to add comments in Excel

 With single cottes   ' test '

How to save file with VBA - How to save file with Macro - in Excel or MS Word

 Sub Macro2()


Shell "winword", vbNormalFocus   

   SendKeys "George W. Bush"

   SendKeys "%{F4}", True

    SendKeys "{ENTER}", True  

   'SendKeys "George W. Bush.txt", True'                       'Comment'  

   'SendKeys "%S"'                                     'Comment'

End Sub


Monday, November 24, 2025

How to open Application in Excel VBA - How to open Notepad in Excel VBA - How to open Notepad and send keys in Excel VBA

 Sub CommandButton1_Click()

    Shell "Notepad.exe", vbNormalFocus

    Dim I As Integer

    SendKeys "one"

    SendKeys "{Enter}"

    SendKeys "two"

End Sub


Monday, November 17, 2025

How to stop applicaion in seconds in excel - step by step macro wait for one second - Excel Sleep

 Application.Wait (Now + TimeValue("00:00:01"))

or

Application.Wait Now + TimeSerial(0, 0, 5)


Note: This is only work in Excel VBA, Not in Word VBA.

How to copy a cell in Excel with VBA and how to show MessageBox in excel - alert in Excel

  Selection.Copy

 MsgBox "Copied ---- " & Selection


Note:- Copy Only a single cell , if more than one cell copied, it will give error

Wednesday, October 29, 2025

Excel Image

 In excel, when you you copy the cells, it will save as image in clipboard

Friday, September 19, 2025

Saturday, April 20, 2024

How to find duplicate values in Excel

 >Open MS Excel

> Select one , two or more columns

> Click on "Conditional Formatting"

> Click on "Highlight cells rules"

> Click on "Duplicate Values"