Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 1300 online users. » 0 Member(s) | 1298 Guest(s) Bing, Yandex
|
Latest Threads |
SELECT statement with MS ...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:35 PM
» Replies: 0
» Views: 1,075
|
SELECT statement with the...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:31 PM
» Replies: 0
» Views: 528
|
Creating hyperlinks in HT...
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 01:23 PM
» Replies: 0
» Views: 818
|
What's new in HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:48 PM
» Replies: 0
» Views: 543
|
What is HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:43 PM
» Replies: 0
» Views: 508
|
Neck isometric exercises
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:44 AM
» Replies: 0
» Views: 807
|
Shoulder shrug
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 462
|
Neck retraction
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 430
|
Neck flexion and extensio...
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 498
|
Neck rotation
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 470
|
|
|
Neck tilt |
Posted by: Qomplainerz - 07-27-2023, 11:42 AM - Forum: Exercises
- No Replies
|
|
Sit or stand with your back straight.
Slowly tilt your head to one side, bringing your ear toward your shoulder.
Hold the stretch for 15-30 seconds.
Return to the starting position and repeat on the other side.
Do this stretch 2-3 times on each side.
|
|
|
Format cells in a range with bold font and yellow background color |
Posted by: Qomplainerz - 07-27-2023, 11:26 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub FormatCellsInRange()
Dim ws As Worksheet
Dim formatRange As Range
'Set the worksheet where the data is located
Set ws = ThisWorkbook.Sheets("Sheet1")
'Set the range of cells to be formatted (adjust the range as per your data)
Set formatRange = ws.Range("A1:B5")
'Apply formatting to the range
With formatRange
.Font.Bold = True
.Interior.Color = RGB(255, 255, 0) 'Yellow color
End With
End Sub
Explanation:
The code defines a subroutine named FormatCellsInRange.
It declares variables for the worksheet (ws) and the range of cells to be formatted (formatRange).
Set ws = ThisWorkbook.Sheets("Sheet1") specifies the worksheet ("Sheet1") where the data is located.
Set formatRange = ws.Range("A1:B5") sets the range A1:B5 to be formatted.
Adjust the range as per your data.
The With block is used to apply formatting to the formatRange.
.Font.Bold = True makes the font bold for all cells in the range.
.Interior.Color = RGB(255, 255, 0) sets the background color of all cells in the range to yellow using the RGB value (255, 255, 0).
|
|
|
Copy data to another worksheet |
Posted by: Qomplainerz - 07-27-2023, 11:24 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub CopyDataToAnotherSheet()
Dim sourceWs As Worksheet
Dim targetWs As Worksheet
Dim lastRowSource As Long
Dim lastRowTarget As Long
'Set the source worksheet where the data is located
Set sourceWs = ThisWorkbook.Sheets("SourceSheet")
'Set the target worksheet where the data will be copied
Set targetWs = ThisWorkbook.Sheets("TargetSheet")
'Find the last row with data in the source worksheet
lastRowSource = sourceWs.Cells(sourceWs.Rows.Count, "A").End(xlUp).Row
'Find the last row with data in the target worksheet
lastRowTarget = targetWs.Cells(targetWs.Rows.Count, "A").End(xlUp).Row
'Copy the data from the source worksheet to the target worksheet
sourceWs.Range("A1:A" & lastRowSource).Copy targetWs.Range("A" & lastRowTarget + 1)
End Sub
Explanation:
The code defines a subroutine named CopyDataToAnotherSheet.
It declares variables for the source worksheet (sourceWs), the target worksheet (targetWs), and the last row with data in each worksheet (lastRowSource and lastRowTarget).
Set sourceWs = ThisWorkbook.Sheets("SourceSheet") specifies the source worksheet ("SourceSheet") where the data is located.
Set targetWs = ThisWorkbook.Sheets("TargetSheet") specifies the target worksheet ("TargetSheet") where the data will be copied.
The lastRowSource variable is determined using sourceWs.Cells(sourceWs.Rows.Count, "A").End(xlUp).Row, which finds the last row with data in column A of the source worksheet.
The lastRowTarget variable is determined using targetWs.Cells(targetWs.Rows.Count, "A").End(xlUp).Row, which finds the last row with data in column A of the target worksheet.
The data from column A of the source worksheet (from A1 to the last row with data) is copied to the target worksheet starting from the next empty row in column A.
|
|
|
Autofill a series of numbers in a column |
Posted by: Qomplainerz - 07-27-2023, 11:23 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub AutofillSeries()
Dim ws As Worksheet
Dim startValue As Integer
Dim endValue As Integer
'Set the worksheet where the series will be created
Set ws = ThisWorkbook.Sheets("Sheet1")
'Specify the start and end values for the series
startValue = 1
endValue = 10
'Enter the start value in the first cell of the series (A1)
ws.Range("A1").Value = startValue
'Autofill the series from the second cell (A2) to the end value (A10)
ws.Range("A1").AutoFill Destination:=ws.Range("A1:A10"), Type:=xlFillSeries
End Sub
Explanation:
The code defines a subroutine named AutofillSeries.
It declares variables for the worksheet (ws), the start value of the series (startValue), and the end value of the series (endValue).
Set ws = ThisWorkbook.Sheets("Sheet1") specifies the worksheet ("Sheet1") where the series will be created.
startValue = 1 and endValue = 10 set the start and end values for the series.
The start value (1 in this example) is entered in cell A1 using ws.Range("A1").Value = startValue.
The ws.Range("A1").AutoFill method is used to autofill the series from cell A2 to cell A10.
Destination:=ws.Range("A1:A10") specifies the destination range for autofilling, and Type:=xlFillSeries indicates that it should be filled as a series.
|
|
|
Loop through columns and clear contents |
Posted by: Qomplainerz - 07-27-2023, 11:21 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub ClearContentsInColumns()
Dim ws As Worksheet
Dim lastColumn As Long
Dim col As Long
'Set the worksheet where the data is located
Set ws = ThisWorkbook.Sheets("Sheet1")
'Find the last column with data in the worksheet
lastColumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
'Loop through each column and clear the contents
For col = 1 To lastColumn
ws.Columns(col).ClearContents
Next col
End Sub
Explanation:
The code defines a subroutine named ClearContentsInColumns.
It declares variables for the worksheet (ws), the last column with data (lastColumn), and a loop counter (col).
Set ws = ThisWorkbook.Sheets("Sheet1") specifies the worksheet ("Sheet1") where the data is located.
The lastColumn variable is determined using ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column, which finds the last column with data in the worksheet.
The For loop iterates through each column from 1 to lastColumn.
ws.Columns(col).ClearContents clears the contents of each cell in the current column (col) of the worksheet.
|
|
|
Sum values based on criteria |
Posted by: Qomplainerz - 07-27-2023, 11:20 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub SumValuesBasedOnCriteria()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim sumResult As Double
Dim targetCriteria As String
'Set the worksheet where the data is located
Set ws = ThisWorkbook.Sheets("Sheet1")
'Find the last row with data in column A
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
'Specify the target criterion in column A
targetCriteria = "Category1"
sumResult = 0 'Initialize the sum
'Loop through each row and calculate the sum of values in column B
For i = 1 To lastRow
If ws.Cells(i, "A").Value = targetCriteria Then
sumResult = sumResult + ws.Cells(i, "B").Value
End If
Next i
MsgBox "Sum of values for " & targetCriteria & ": " & sumResult
End Sub
Explanation:
The code defines a subroutine named SumValuesBasedOnCriteria.
It declares variables for the worksheet (ws), the last row with data (lastRow), a loop counter (i), the sum result (sumResult), and the target criterion (targetCriteria) to calculate the sum for.
Set ws = ThisWorkbook.Sheets("Sheet1") specifies the worksheet ("Sheet1") where the data is located.
The lastRow variable is determined using ws.Cells(ws.Rows.Count, "A").End(xlUp).Row, which finds the last row with data in column A.
targetCriteria = "Category1" specifies the criterion (Category1) for which the sum will be calculated.
The For loop iterates through each row from 1 to lastRow.
The If statement checks if the value in column A (ws.Cells(i, "A").Value) matches the targetCriteria.
If it does, the value in column B (ws.Cells(i, "B").Value) is added to the sumResult.
Finally, a message box displays the sum of values for the specified criterion.
|
|
|
Create a hyperlink with VBA |
Posted by: Qomplainerz - 07-27-2023, 11:10 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub CreateHyperlink()
Dim ws As Worksheet
'Set the worksheet where the hyperlink will be created
Set ws = ThisWorkbook.Sheets("Sheet1")
'Create a hyperlink in cell A1
ws.Hyperlinks.Add _
Anchor:=ws.Range("A1"), _
Address:="https://www.example.com", _
TextToDisplay:="Visit Example Website"
End Sub
Explanation:
The code defines a subroutine named CreateHyperlink.
It declares a variable for the worksheet (ws) where the hyperlink will be created.
Set ws = ThisWorkbook.Sheets("Sheet1") specifies the worksheet ("Sheet1") where the hyperlink will be added.
The ws.Hyperlinks.Add method is used to create a hyperlink.
Anchor:=ws.Range("A1") sets cell A1 as the anchor for the hyperlink (where the link will be displayed).
Address:="https://www.example.com" specifies the URL or address to which the hyperlink points.
TextToDisplay:="Visit Example Website" sets the text that will be displayed for the hyperlink in cell A1.
|
|
|
Split text in cells with VBA |
Posted by: Qomplainerz - 07-27-2023, 11:09 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub SplitTextInCells()
Dim sourceRange As Range
Dim cell As Range
Dim parts As Variant
'Set the range where the text is located (assuming data starts from A1)
Set sourceRange = Range("A1:A5")
'Loop through each cell in the range
For Each cell In sourceRange
'Split the text in the cell based on the delimiter
parts = Split(cell.Value, ",")
'Place the split parts in adjacent columns
cell.Offset(0, 1).Resize(1, UBound(parts) + 1).Value = parts
Next cell
End Sub
Explanation:
The code defines a subroutine named SplitTextInCells.
It declares variables for the source range (sourceRange), a loop variable (cell), and an array variable to hold the split parts (parts).
Set sourceRange = Range("A1:A5") specifies the range A1:A5 where the text is located.
The For Each loop is used to loop through each cell in the sourceRange.
The Split function is used to split the text in the cell based on the delimiter ("," in this example).
The result is stored in the array variable parts.
The split parts are then placed in adjacent columns to the right of the original cell.
cell.Offset(0, 1) refers to the cell next to the current cell, and Resize(1, UBound(parts) + 1) adjusts the size of the destination range to fit the number of split parts.
The split parts are written to the destination range using .Value = parts.
|
|
|
Count colored cells with VBA |
Posted by: Qomplainerz - 07-27-2023, 11:07 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Sub CountColoredCells()
Dim countColor As Long
Dim cell As Range
Dim targetColor As Long
'Specify the target color (RGB value) to count
targetColor = RGB(255, 0, 0) 'Red color in this example
countColor = 0 'Initialize the counter
'Loop through each cell in the range
For Each cell In Range("A1:A10")
'Check if the cell's background color matches the target color
If cell.Interior.Color = targetColor Then
countColor = countColor + 1 'Increment the counter
End If
Next cell
MsgBox "Number of cells with the target color: " & countColor
End Sub
Explanation:
The code defines a subroutine named CountColoredCells.
It declares variables for the counter (countColor), a loop variable (cell), and the target color (targetColor) you want to count.
In this example, we use the RGB value for the color red (255, 0, 0).
The counter countColor is initialized to 0.
The For Each loop is used to loop through each cell in the range "A1:A10".
The If statement checks if the background color of the current cell matches the target color (targetColor = RGB(255, 0, 0)).
If there is a match, the counter countColor is incremented by 1.
Finally, a message box displays the number of cells with the target color.
|
|
|
Calculate factorial of a given number in VBA |
Posted by: Qomplainerz - 07-27-2023, 11:04 AM - Forum: Excel VBA Tutorials
- No Replies
|
|
Example:
Function Factorial(number As Integer) As Double
Dim result As Double
Dim i As Integer
result = 1
'Calculate factorial
For i = 1 To number
result = result * i
Next i
Factorial = result
End Function
Sub CalculateFactorial()
Dim num As Integer
'Enter the number for which you want to calculate the factorial
num = 5
'Calculate and display the factorial using the Factorial function
MsgBox "Factorial of " & num & " is: " & Factorial(num)
End Sub
Explanation:
The code defines a custom function named Factorial, which calculates the factorial of a given number.
The Factorial function takes an integer number as input and returns a Double as the result.
A variable result is initialized to 1, as the factorial of 0 is 1.
The For loop runs from 1 to number, and in each iteration, the result is multiplied by i.
The Factorial function returns the final result as the factorial of the input number.
The CalculateFactorial subroutine demonstrates how to use the Factorial function.
A number (5 in this example) is assigned to the variable num.
The factorial of num is calculated using the Factorial function and displayed in a message box using MsgBox.
|
|
|
|