+ Reply to Thread
Results 1 to 10 of 10

Vba not working afetr adjusting rows and columns

  1. #1
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Vba not working afetr adjusting rows and columns

    Hi

    I am kindly asking for help on VBA code. The code was working well but when I adjusted rows and columns of my worksheets its no longer working. Please not that there are two sales data in one sheet: one is for ZW$ (Column G to Y) and one for US$ (Column AH to AZ). Customer statements are two in one sheet, one for ZW$ and the other one for US$ and the same applies with opening balances.

    Please find the attached worksheet including VBA code.


    Thank you.

    Regards,

    Sunboy

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Vba not working afetr adjusting rows and columns

    This file contains no VBA code to review.

  3. #3
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Vba not working afetr adjusting rows and columns

    Hi

    My apologies I have attached but it is not showing. Below is the code.

    Thank you.

    Sub sintek()
    Dim ShtArr, Temp(), Data, i As Long, ii As Long, x As Long, Cust As String, dt As Date
    Application.ScreenUpdating = False
    ShtArr = Array("Opening Balances", "Sales Data", "Receipts")
    ReDim Temp(1 To 1000, 1 To 6)
    With Sheets("Customer Statement")
    .Rows(10 & ":" & .Rows.Count).Delete
    Cust = .Range("A6").Value
    For i = LBound(ShtArr) To UBound(ShtArr)
    With Sheets(ShtArr(i))
    Data = .Cells(1).CurrentRegion
    For ii = 2 To UBound(Data, 1)
    If i = 0 Then
    dt = Format(DateSerial(Year(Date), Month(Date), 1), "dd/mm/yyyy")
    If Data(ii, 2) = Cust Then x = x + 1: Temp(x, 1) = dt: Temp(x, 6) = Data(ii, 4)
    ElseIf i = 1 Then
    If Data(ii, 3) = Cust Then
    x = x + 1
    Temp(x, 1) = Data(ii, 1)
    Temp(x, 3) = Data(ii, 5)
    Temp(x, 4) = Data(ii, 16)
    End If
    Else
    If Data(ii, 3) = Cust Then
    x = x + 1
    Temp(x, 1) = Data(ii, 1)
    Temp(x, 2) = Data(ii, 5)
    Temp(x, 3) = Data(ii, 6)
    Temp(x, 5) = Data(ii, 7)
    End If
    End If
    Next ii
    End With
    Next i
    .Range("A10").Resize(x, 6) = Temp
    With .Range("A10:F" & .Cells(.Rows.Count, 1).End(xlUp).Row)
    .Resize(.Rows.Count - 1).Columns(6).Offset(1).Formula = "=sum(F10-E11+D11)"
    .Sort .Range("A10"), xlAscending
    .Borders.LineStyle = xlContinuous
    End With
    End With
    Application.ScreenUpdating = True
    End Sub

  4. #4
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Vba not working afetr adjusting rows and columns

    Hi

    Please find the attached excel sheet including the above VBA code. I hope its now clear.

    Thank you.

    Regards.

    Sunboy
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Vba not working afetr adjusting rows and columns

    Please add the code between tags #, according to the forumrules.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  6. #6
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Vba not working afetr adjusting rows and columns

    Change
    Please Login or Register  to view this content.
    to the number off rows and columns jou need.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: Vba not working afetr adjusting rows and columns

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  8. #8
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Vba not working afetr adjusting rows and columns

    hi

    what are code tags?

  9. #9
    Forum Contributor
    Join Date
    07-06-2020
    Location
    zimbabwe
    MS-Off Ver
    Excel 365
    Posts
    478

    Re: Vba not working afetr adjusting rows and columns

    Hi

    My apologies I do not know much about VBA, I got this VBA on this forum after requesting for help. Sintek, the forum expert gave me the above VBA and it worked well till I changed the columns and rows. If I knew what code tags are, I should have given you, but I do not know them.

    My apologies again.

    Regards

    Sunboy

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,937

    Re: Vba not working afetr adjusting rows and columns

    Read my post on how to add code tags. If you still do not understand then review the rules you agreed to when you joined.

    No further help until OP complies with Code Tag insertion.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Content control editing impossible in header afetr enforcing protection
    By Pepe Le Mokko in forum Word Formatting & General
    Replies: 15
    Last Post: 12-19-2019, 04:47 AM
  2. [SOLVED] adjusting vba code to make it dynamic as rows data rows differ
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-26-2018, 10:37 PM
  3. [SOLVED] Row height adjusting macro not working on rows with merged cells
    By Nbisgaard in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-06-2015, 05:32 AM
  4. SUMIF Rows and Columns Not working
    By SHUTTEHFACE in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-29-2014, 05:59 AM
  5. Adjusting columns sizes within certain rows..
    By bankexcel in forum Excel General
    Replies: 2
    Last Post: 07-11-2014, 05:03 PM
  6. Adjusting Size of Rows and Columns
    By Aumkar in forum Excel General
    Replies: 2
    Last Post: 02-15-2010, 01:57 AM
  7. [SOLVED] ADJUSTING COLUMNS
    By Just Me in forum Excel General
    Replies: 1
    Last Post: 01-17-2006, 11:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1