[Solved] How to write VBA code to copy the cell data based on the selection of the rows and columns [closed]

it’d be something like follows: Sub MyMacro() With Selection Sheets.Add.name = .Cells(1, 1) .Offset(1).Resize(.Rows.Count – 1).Copy Sheets(.Cells(1, 1).value).Range(“A1”) End With End Sub feel free to add all necessary checks for assure error handling (e.g.: no selection made, only 1 row selected, target sheet already existent, …) of which you may find dozens of examples around … Read more

[Solved] search for string in text file in vb and print lines

A very bad formed question for this site. It’s good for you to spend some time to read the rules. Anyway, this is from me. Const ForReading = 1, ForWriting = 2 Dim FSO, FileIn, FileOut, strTmp Set FSO = CreateObject(“Scripting.FileSystemObject”) Set FileIn = FSO.OpenTextFile(“shar.txt”, ForReading) Set FileOut = FSO.OpenTextFile(“sha.txt”, ForWriting, True) Do Until FileIn.AtEndOfStream … Read more

[Solved] How to handle this scenario in single SSIS package?

This will help. how-to-read-data-from-an-excel-file-starting-from-the-nth-row-with-sql-server-integration-services Copying the solution here in case the link is unavailable Solution 1 – Using the OpenRowset Function Solution 2 – Query Excel Sheet Solution 3 – Google It Google it, The information above is from the first search result 3 solved How to handle this scenario in single SSIS package?

[Solved] Cut specified number of rows in selected range VBA

The following will achieve what you are wanting, it will generate 18 random numbers between 2 and your last row with data, in your case row 180 and then copy that row into the next free row in Sheet2: Sub foo() Dim wsOriginal As Worksheet: Set wsOriginal = ThisWorkbook.Worksheets(“Sheet1”) Dim wsDestination As Worksheet: Set wsDestination … Read more

[Solved] Count, insert row, paste in other tab [closed]

try the code below : Sub test() Dim ws As Worksheet Dim ws2 As Worksheet Set ws = ThisWorkbook.Sheets(“sheet1”) Set ws2 = ThisWorkbook.Sheets(“sheet2”) lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row lastRow2 = ws2.Cells(ws2.Rows.Count, 1).End(xlUp).Row i = 1 Do While ws.Cells(i, 1).Value = ws2.Cells(i, 1).Value i = i + 1 Loop For j = i To lastRow lastRow2 = … Read more

[Solved] do while loop in excel vba error

While Den Temple is correct, and you really should Dim variables independently, the real problem here is with the logic of: For clm = 1 To 5 ClmTtl = 0 For copyRow = 1 To percRows ClmTtl = ClmTtl + Sheets(1).Cells(MyRows(copyRow), clm).Value Next Next This clears ClmTtl each time, without doing anything with the total … Read more

[Solved] find and remove partial duplicates in excel

In an unused column to the right, put this array formula¹ in the second row. =ISNUMBER(MATCH(LEFT(A2, MIN(IFERROR(FIND({0,1,2,3,4,5,6,7,8,9}, A2)-1, 1E+99)))&MID(A2, FIND(“.”, A2), 9),A:A, 0)) Finalize with CSE and fill down as necessary. Use Data ► AutoFilter to filter on that column for TRUE and delete the visible rows. ¹ Array formulas need to be finalized with … Read more

[Solved] Export Power Queries from One Workbook to Another with VBA

I was able to solve it by using the Workbook.Query object. here is my solution. Public Sub FunctionToTest_ForStackOverflow() ‘ Doug.Long Dim wb As Workbook ‘ create empty workbook Set NewBook = Workbooks.Add Set wb = NewBook ‘ copy queries CopyPowerQueries ThisWorkbook, wb, True End Sub Public Sub CopyPowerQueries(wb1 As Workbook, wb2 As Workbook, Optional ByVal … Read more