How I copy the selected content in a row. With the help of following code I got the line number of the row. but i don't have any idea to copy the content of the particular row
on mouseUp
put the dgHilitedLines of group "data" into theLine
answer theLine
end mouseUp
Set the global clipboarddata property to set the clipboard:
on mouseUp
put the dgHilitedLines of group "data" into myLine
set the clipboarddata["text"] to line myLine of the dgText \
of grp "data"
end mouseUp
Related
I'm new to VBA and am trying to create a window order form to fit a landscape 8x11.5 page. The rows are set up as followed:
Each cell has a different data validation dropdown menu. I'd like to be able to copy this template and paste it below Line #1.
In this case Line #2 would begin at A5.
This code does the trick very crudely:
Sub CopyTemplate()
Worksheets("WINDOW TEMPLATE").Range("A3:R4").Copy Range("A5:R6")
End Sub
As you can see, the job is done crudely but I'd have to create a macro for each new line manually.
Is there a way to replace the destination range with a variable that will find the next available empty row to create Line 2 like
In the case of Line 2 it would be A7 (and then every two lines would be the loop I guess).
I've seen several example similar to mine but they never do what I need or I'm too inexperienced to retrofit the code to my needs. As I understand it, .End finds the next blank cell but all it seems to do is goto the bottom of the sheet.
Find the last numbered item in Col A then move down two rows:
Sub CopyTemplate()
Dim c as range
With Worksheets("WINDOW TEMPLATE")
Set c = .Cells(.Rows.Count, "A").End(xlUp).Offset(2) 'move down two rows from last numbered item
.Range("A3:R4").Copy c
c.value = c.offset(-2).value + 1 'increment item#
End With
End Sub
I have checkboxes set for each line. I would like that if the checkbox is selected after running the macro, values from one column were automatically copied to the clipboard. How to do it? So far I have written something like this.
Sub CopyCheckedRowsToClipboard()
Dim ctCB As CheckBox
'Process all checkboxes in the ActiveSheet
For Each ctCB In ActiveSheet.CheckBoxes
'If the checkbox is checked, select the row, then copy
If ctCB = 1 Then
ctCB.TopLeftCell.EntireRow.Select
ctCB.Copy
End If
Next ctCB
End Sub
What am I doing wrong?
The table I have:
My table
The effect I want to get:
Effect macro
What I'm trying to do is update amount from one line to another in Excel. They don't have any key that combines but they are in pattern. Always start with Item Group and about 3-7 lines after is End of Item Group. I want to grab the amount from End of Item Group and update the line in Item Group but always Item Group will be first then End of Item Group.
I could upload to SQL if it's easier to work on or Access.
This is the problem.
This is what I'm trying to accomplish:
After this update I wanted to delete every line after item group but only up to end of item group.
So basically if you don't already have the Developer tab, you would need to go to Options > Customize Ribbon > Click 'Developer'
Then click on VB Editor on Developer tab and right click in project area and select "insert new module". In the new module insert this code and save.
To make it easy to run, you can go to Developer tab > Insert > Button. Then right-click on the button and assign it to this macro you just created so everytime you want to update the item group values you can click the button. If the button doesn't let you "assign a macro" then you probably inserted the wrong type of button.
Option Explicit
Sub UpdateValues()
Dim itemCol As Long
Dim lastRow As Long
Dim row As Long
Dim lastEnd As Double: lastEnd = 0.0
' set reference to your worksheet
With ThisWorkbook.Worksheets("your sheet name")
' set column with title 'Item_Type' in Row 1
For row = 1 To 20
If Trim(CStr(.Cells(1, i).Value)) = "Item_Type" Then itemCol = i
Next
' find last row of Item_Type column
lastRow = .Cells(.Rows.Count, itemCol).End(xlUp).Row
' loop backwards thru rows
For row = lastRow To 1 Step -1
' if cell contains word 'end'
If InStr(LCase(CStr(.Cells(row, itemCol).Value)), "end") Then
' set our group value
lastEnd = .Cells(row, itemCol+1).Value
' if lowercase(cell) = 'item group'
ElseIf LCase(CStr(.Cells(row, itemCol).Value)) = "item group" Then
' put end value in the cell
.Cells(row, itemCol+1).Value = lastEnd
End If
Next row
End With
End Sub
I have a column of data. I want to select the cells that contain a hyperlink and print just the values of those cells.
I have the following code to extract the hyperlink. I want if there is a link in cell A1 called "hello", it doesn't print the link itself, but prints "hello".
Sub ExtractHL()
Dim HL As Hyperlink
For Each HL In ActiveSheet.Hyperlinks
HL.Range.Offset(0, 1).Value = HL.Address
Next
End Sub
The other idea I just had was to say that if a cell in a row DOESN'T contain a hyperlink, then to delete that row, but I'm not sure how to negate the "for each HL in sheet" line.
Changing the "HL.Address" to HL.Range pastes that range.
i create some table, and make a datestamp when i enter data
in column "A" the date is shown in column "E" , so i know when data is entered.
I put checkbox in column "F", but I need help with next:
When checkbox is checked the date must be written in column "G"
The background from "A to D" (but only in this row) must be changed to red color
The data from A, B and C must be copied to another sheet also in A,B and C
I hope someone will help me because i stuck :(
I also attack a screenshot.
Thanks in advance
The procedures will help you get the macro operational, ensure you try the code on a copy of your workbook
Add a command button (ActiveX control) and paste the macro
Note: You need to ensure that you place the Command Button in the worksheet where you have your check boxes.
Step 1:
Copy the “LoopCkBoxesAddDateStampClrCelsCopy()” macro
Sub LoopCkBoxesAddDateStampClrCelsCopy()
Dim lRow As Long
Dim CkBx As OLEObject
'For/Next loop cycles through all checkboxes in worksheet
For Each CkBx In ActiveSheet.OLEObjects
lRow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
'If the checkbox is checked then accomplish the lines of code between the If/End If
'The part after the "And" ensures that if a date is in the cell it will not be over written
If CkBx.Object.Value = True And CkBx.TopLeftCell.Offset(, 1).Value = "" Then
'Next line of code puts the date in first cell to left of the checkbox
CkBx.TopLeftCell.Offset(, 1).Value = Format(Date, "mm-dd-yyyy")
'Next line of code colors the first 4 cells in checkboxs' row
CkBx.TopLeftCell.Offset(, -5).Resize(, 4).Interior.Color = vbRed
'Next line of code copies the first 3 cell in the checkbox row to the first empty row on sheet 2
Sheet2.Cells(lRow, 1).Offset(1).Resize(, 3).Value2 = CkBx.TopLeftCell.Offset(, -5).Resize(, 3).Value2
End If
Next CkBx 'loops to the next checkbox
End Sub
Note: If you plan on pasting your cells to a different worksheet, please change both Sheet2s in the code.
Step 2:
On the Developer tab, in the Controls group, click Insert, and then under ActiveX Controls, click the Command Button.
Step 3:
Click the worksheet location where you want the command button to appear.
Step 4:
Right click the button, click View Code. This will launch the Visual Basic Editor.
Step 5:
In the VBE, highlight the Private Sub CommandButton1_Click() and the End Sub, and Paste the macro
Step 6:
Close the Visual Basic Editor, and click Design Mode Button image to ensure design mode is off.
Step 7:
Select the checkboxes in your worksheet and click the button to run the macro