Code not to resize if count is 1

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello guys
With the help of JohnnyL's code I am trying to add a few lines from it to another application. But I am not able to place or edit the code properly. If I add those lines to the code, the data gets deleted. Can someone tell me where am I going wrong.?
Johnnyl's code where it worked in another application which I am referring to is
Resize of cells in different codes displays an error. Required to edit to count <=0 or >0
This is the link to my workbook.
edit code not to resize when count is1.xlsm
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
This is the last code I tried but still it is not working.
Rich (BB code):
Option Explicit
Dim LedgerCount                         As Long
Sub SaveAsBankXML()
Dim LastColumnNumberInRow               As Long
    Dim x                               As Long
    Dim xmlFile                         As Object
    Dim LastColumnLetterSheetImportBank As String
    Dim strData                         As String
    Dim strTempFile                     As String

' if data is not entered

    If Sheets("BankData").Range("A3") = vbNullString Then
        MsgBox "Enter Data in A3."
        Exit Sub
    End If


'ClearOldWorkings

    With Sheets("ImportBank")
        .Range("A3:BD" & .Range("A" & .Rows.Count).End(xlUp).Row).ClearContents                   '   Erase old data of import sales from A3:BL range of data
    End With

    x = Sheets("BankData").Range("A3:B" & Sheets("BankData").Range("A" & Rows.Count).End(xlUp).Row).Rows.Count                            ' Get count of rows to write to file
'
    LastColumnNumberInRow = Sheets("ImportBank").Cells(2, Sheets("ImportBank").Columns.Count).End(xlToLeft).Column  ' Get last column number in row
'
    LastColumnLetterSheetImportBank = Split(Cells(1, (Sheets("ImportBank").Cells.Find("*", , xlFormulas, _
            , xlByColumns, xlPrevious).Column)).Address, "$")(1)                                            ' Get last column letter used in Sheets("ImportBank")

    LedgerCount = Sheets("BankData").Range("A3:A" & Sheets("BankData").Range("A" & _
            Rows.Count).End(xlUp).Row).Rows.Count                                               ' Get count of rows to write to file
'
        If LedgerCount > 1 Then
        With Sheets("ImportBank")
        .Range("A2:" & LastColumnLetterSheetImportBank & _
                LedgerCount + 1).FillDown                                                       '   If LedgerCount > 1 Then Create range needed to copy
'
        .Range("A2").Resize(LedgerCount, LastColumnNumberInRow).Copy                            '
    End With
End If
'
    strData = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("Text")                                       ' Save contents into strData
'
    strTempFile = "C:\Users\" & Environ("username") & "\Desktop\Bank.xml"
    CreateObject("Scripting.FileSystemObject").CreateTextFile(strTempFile, True).Write strData                      ' Write the data to file
'
    Application.CutCopyMode = False

MsgBox ("File saved on Desktop as Bank.XML Rename the File. Copy path and paste in tally.")
    
  Sheets("BankData").Activate
  Range("A2").Select
     
End Sub
 
Upvote 0
I have found one error due to which I was not able to generate the right xml format. I have deleted columns BJ:BL and shifted them a new sheet which also needs to be resized with the other sheet.
resize 2 sheets.xlsm
The above app was working and could generate xml for 6000 row of data only. So, I decided to go to import unlimited data and instead of dragging the formula in the importBank and Extract sheet, I am trying to write a code to resize the data if both sheets with Bank Data sheet,
 
Upvote 0
What the heck did you do to that file in post #3? There are no code modules & the file size is like 35MB.
 
Upvote 0
It is one of my old projects where I could generate limited number of rows. By referring your old codes, I am trying to edit and make it unlimited number of rows. That is all.
 
Upvote 0
There are no code modules
I removed it because once you play the code it will create havoc with the data. I pasted it in one of the sheet as only a part of it is working.
 
Upvote 0
Post #3 has no code. I am not gonna rewrite the entire code.
 
Upvote 0

Forum statistics

Threads
1,216,089
Messages
6,128,760
Members
449,466
Latest member
Peter Juhnke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top